runner.spec

A living technical document describing an Ambient Runner, a Python web application that runs one coding session inside a temporary session pod. It explains how the runner starts Claude Code, exchanges messages, stores results, and streams live events.

In plain words
What is it for?
Use it to understand or change session execution, subprocess management, real-time message streaming, durable message recording, and the runner’s HTTP event endpoints.
Why use it?
It gives developers a shared description of the runner’s current behavior and its connections to the control plane, message store, and client protocols.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/ambient-code/platform/runner.spec
Clone the repo
git clone --depth 1 https://github.com/ambient-code/platform
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,589 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.05589
Opus 5 $0.00000 $0.02795
Sonnet 5 $0.00000 $0.01118
Haiku 4.5 $0.00000 $0.00559

Measured yesterday against content hash 9475d9742c18, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

runner.spec scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

specs/agents/runner.spec.md · 505 lines

How it starts

The opening of the file, as written. The whole thing — 505 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Ambient Runner Spec

Date: 2026-04-05 Status: Living Document — current state documented Related: ../control-plane/control-plane.spec.md — CP provisioning, token endpoint, start context assembly


Overview

The Ambient Runner is a Python FastAPI application that runs inside each session pod. It is the execution engine for one session: it owns the Claude Code subprocess lifecycle, bridges between the AG-UI HTTP protocol and the gRPC message store, streams results in real time, and exposes a local SSE tap for live event observation.

One runner pod runs per session. The pod is ephemeral — created by the CP when a session starts, deleted when the session ends.

CP creates runner pod
    │  env vars (SESSION_ID, INITIAL_PROMPT, AMBIENT_GRPC_URL, ...)
    ▼
Runner Pod (FastAPI + uvicorn)
    │
    ├── gRPC listener ←── WatchSessionMessages (api-server)
    │        │
    │        └──► bridge.run() ──► Claude Code subprocess
    │                    │
    │                    ├──► PushSessionMessage (api-server)       ← durable record
    │                    └──► _active_streams[thread_id] queue      ← SSE tap
    │
    └── HTTP endpoints
          ├── GET /events/{thread_id}      ← live SSE tap (drained by backend proxy)
          ├── POST /                       ← AG-UI run (HTTP path, backup)
          ├── POST /interrupt
          └── GET /health

What the Runner Is

The runner is a bridge. It translates between three different message-passing systems:

System Protocol Direction Purpose
api-server gRPC WatchSessionMessages inbound User messages that trigger Claude turns
Claude Agent SDK subprocess stdin/stdout bidirectional Drives Claude Code execution
api-server gRPC PushSessionMessage outbound Durable conversation record (assistant turns)
SSE tap GET /events/{thread_id} outbound Live event stream for the frontend and CLI

The runner has no database. All persistent state (session messages, session phase) lives in the api-server.

Read the full file on GitHub · 505 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 505 lines · 0 tokens per session scan A 9475d9742c18

Subscribe to this mod's changes

runner.spec is an agent published in the GitHub repository ambient-code/platform (129 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 5,589 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories