Skip to main content
The custom runner lets you connect RemoteAgent.CHAT to any command-line tool that follows a simple contract: read a prompt from stdin, write output to stdout. This covers shell scripts, Python scripts, local model wrappers, internal tools, or any binary you build yourself.

Requirements

  • Your binary must be executable and on the machine running the agent.
  • It must read the prompt from stdin and write the response to stdout.
  • Exit code 0 indicates success; any non-zero exit code is treated as an error.

Setup

Pass the path to your binary with the --runner-bin flag:
The binary path is saved in ~/.remoteagent/agents/{agentId}.json and used each time the agent receives a command.

How it works

When the agent receives a command, the runner:
  1. Spawns the binary as a child process
  2. Writes the prompt string to the process’s stdin
  3. Closes the stdin stream (signals EOF to the binary)
  4. Reads stdout progressively and forwards chunks to Telegram in real time
  5. Waits for the process to exit, then marks the session as done
Your binary should write output as it produces it (don’t buffer everything until the end) for the best streaming experience in Telegram.

Example — bash script

A minimal bash script that wraps a local llm command:
Make it executable:

Example — Python script

A Python script that calls the OpenAI API directly:

Example — Ollama wrapper

Passing environment variables

If your binary needs environment variables (API keys, config paths), set them in the shell environment where you run remoteagent start. They are inherited by child processes:
Alternatively, use a wrapper script that sets the variables before calling the real binary.

Pros and cons