Execution Boundary
How run workers, the agent runtime, harnesses, and LLMs fit together.
Every Agentty request for model reasoning or generation goes through a worker-owned execution boundary: Run Worker → Agent Runtime → Harness → LLM. This includes session turns, titles, focused reviews, summaries, commit messages, review-request metadata, and conflict assistance.
flowchart TD
A[Application workflow] -->|SessionRunClient or RunClient| W[Run Worker]
W -->|waits for a turn slot| S[Scheduler]
W -->|dispatches request| R[Agent Runtime]
R -->|selects adapter| H[Harness]
H -->|calls| L[LLM]
R -.->|turn events and result| W- Run Worker: admission, ordering, cancellation, recovery, and execution policy.
- Agent Runtime: adapter composition, dispatch, and provider lifecycle.
- Harness: the agent loop, the LLM behind it, and observed activity.
Execution graph nodes take the same path: Graph Executor admits them under the limits of Graph Resources and hands each to a Run Worker lane.
Crates🔗
| Component | Crates | Responsibility |
|---|---|---|
| Scheduler | ag-scheduler | Session admission |
| Run Worker | ag-worker | Admission, scheduling, cancellation, recovery |
| Agent Runtime | ag-runtime | Adapter composition, dispatch, provider lifecycle |
| Shared contracts | ag-contracts, ag-protocol | Requests, events, policy types, response schemas |
| Harness (external) | ag-agent | CLI and app-server adapters, policy enforcement |
| Harness (native) | ag-harness, ag-harness-cli | Model loop run in process by ag-agent, and CLI |
| LLM | None | Reached through the harness |
| Supporting | ag-session, ag-store | Session models, model selection, and persistence |
Dependency Rule🔗
Only ag-worker depends on ag-runtime, and only ag-runtime depends on ag-agent. Only ag-harness-cli and ag-agent may depend on ag-harness. Applications configure worker handles and import shared types from ag-contracts. A host that enables harness sessions must also call ag_worker::dispatch_sandbox_helper first in main, before starting any runtime, so its own executable serves as the native sandbox helper; without the call, commands run unsandboxed and every turn warns about it.
Commands a host runs on its own behalf in the native sandbox, such as commit hooks, involve no model. They take the same worker, runtime, and harness path through RuntimeConfig::session_commands, without scheduler admission.
The check-execution-boundary hook enforces this boundary on every commit: dependency rules cover all workspace dependencies, including test code, and source checks keep raw adapter use and agent CLI launches out of production code outside the execution crates.
See Module Map for ownership and Runtime Flow for orchestration and recovery.