AgentGate
Remote AI CLI control via Telegram and Slack with multi-agent orchestration. Control AI coding agents from your phone while they work on your infrastructure.
What is AgentGate?
AgentGate is a Python orchestration service that bridges messaging platforms (Telegram, Slack) with AI coding agents running on remote machines. It lets you monitor, approve, and redirect AI agent work from your phone - solving the problem of agents hitting decision points or errors when you’re away from your desk. It supports multiple concurrent agent sessions, approval workflows, real-time output streaming, and command routing.
The Problem
AI coding agents run in terminal sessions on remote machines. When you step away, you lose visibility into what they’re doing. An agent might hit a permission error, make a questionable architectural decision, or need approval to proceed with a destructive operation - and without you there, it either blocks indefinitely or makes the wrong call. I needed a way to stay in the loop from any device.
How I Built It
The core architectural decision was treating AgentGate as a gateway, not a wrapper. Rather than embedding agent logic, it intercepts the stdin/stdout streams of any CLI-based AI agent and routes them through messaging platform APIs. This means it works with Claude Code, Aider, or any future agent that uses a terminal interface - no vendor lock-in.
The trickiest part was handling bidirectional real-time communication without overwhelming the messaging platform rate limits. Telegram and Slack both throttle message sends, so I implemented an output buffering system that batches rapid agent output into readable chunks while keeping interactive prompts (approval requests, error messages) immediate and unbatched.
Multi-agent support required session isolation - each agent runs in its own subprocess with independent I/O routing. A session manager maps Telegram/Slack threads to agent sessions, so you can run three different agents on three different repos and keep the conversations separate.
Architecture
The service runs as a persistent daemon that spawns agent subprocesses on demand. A message router dispatches incoming Telegram/Slack messages to the correct agent session based on thread ID. Outbound agent output flows through a formatter that strips ANSI escape codes and converts terminal output into readable markdown for the messaging platform.
Impact
- Remote AI agent control from any device - approve, redirect, or kill agent tasks from your phone
- Multi-agent orchestration with isolated sessions and independent I/O routing
- Platform-agnostic design: works with any CLI-based AI agent, not just one vendor