Agent Runtime
How the agent runtime composes harness adapters and dispatches requests.
ag-runtime composes harness adapters, dispatches worker-admitted requests, and coordinates provider lifecycle. It defines one protocol for every harness, whether CLI, app server, or in process.
Connections🔗
flowchart LR
W[Run Worker] -->|admitted request and resolved policy| R[Agent Runtime]
R -->|adapter contract| H[Harness adapters]
R -.->|turn events and result| W
C[ag-contracts] -.->|requests, events, settings, errors| ROnly the Run Worker calls the runtime, and only the runtime constructs harness adapters. Provider transports never reach application workflows.
Responsibilities🔗
- Dispatch: select the adapter for the requested agent and forward the request, preserving cancellation, usage, and provider-call budgets.
- Policy: carry the worker's resolved execution policy to the adapter, which translates and enforces it. A retained provider process must match the requested policy before reuse.
- Lifecycle: keep provider processes behind runtime objects and clean them up after cancellation or shutdown.
- Steering: forward a user prompt into the running session turn of an adapter that accepts mid-turn input. Other adapters reject it, and the host keeps the prompt for a later turn.
Shared requests, events, settings, and errors live in ag-contracts. Frontend policy, mailbox scheduling, and persistence stay outside the runtime.