Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(agent-harness): normalize emphasis and table formatting

Steven Enamakeld8bfd4a0ede9
diff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.md
index c30b06076f..cd5f01f6f1 100644
--- a/gitbooks/developing/architecture/agent-harness.md
+++ b/gitbooks/developing/architecture/agent-harness.md
@@ -214,11 +214,11 @@ Freezing the prompt is only one third of the contract, and the other two are eas
- **The tool block counts, and it comes _first_.** Every prefix cache in production renders the tool catalogue ahead of the conversation, a chat template has to put it somewhere the model reads before the first user turn. OpenAI's automatic cache, Anthropic's `cache_control` (tools → system → messages), DeepSeek's context cache and any vLLM/SGLang radix cache all work this way. So a `tools` array that changes between turns invalidates the frozen system prompt too, and the JSON key order of the request body (which puts `messages` before `tools`) says nothing about it. The mid-session Composio reconcile is still correct, a tool surface that lies about what the model can call is worse than a cold prefill, but it must fire only on a real capability change and be byte-stable otherwise. `connected_set_hash` sorts before hashing so a reordered backend response never reaches a rebuild, and `collect_orchestrator_tools` sorts the connected-toolkit enum for the same reason.
- **History must be append-only.** Turn N's serialization has to survive verbatim as the opening of turn N+1. `pair_tool_cycles` drops half-finished tool cycles at serialization time, so its verdict for an entry must depend only on that entry and its immediate neighbour, never on anything appended later, or an earlier message's presence flips retroactively and the prefix moves under the cache. Context compaction is the one deliberate exception; it rewrites the middle and pays for a re-prefill.
-A resumed session's replayed prefix is folded into `Agent::history` rather than spliced into one request, so the request, the following turn and the persisted transcript all read the same sequence. Splicing it cost the conversation twice: the next turn went out without it, and the transcript written afterwards (serialized from `history`) held only the new turn, which the _next_ resume then read back, truncating the thread a little further on every restart.
+A resumed session's replayed prefix is folded into `Agent::history` rather than spliced into one request, so the request, the following turn and the persisted transcript all read the same sequence. Splicing it cost the conversation twice: the next turn went out without it, and the transcript written afterwards (serialized from `history`) held only the new turn, which the *next* resume then read back, truncating the thread a little further on every restart.
#### A stable prefix only pays out when the wire says so
-Keeping the bytes stable is necessary, not sufficient: the provider still has to be _told_ to cache, and two providers need telling explicitly.
+Keeping the bytes stable is necessary, not sufficient: the provider still has to be *told* to cache, and two providers need telling explicitly.
- **Anthropic caches nothing without `cache_control` markers, and its OpenAI-compatible endpoint cannot carry them**, Anthropic documents prompt caching as unsupported on that path and reports `prompt_tokens_details` as always empty. A `cloud_providers` entry with `auth_style = "anthropic"` is therefore built as the crate's native Messages adapter (`tinyinference_llm::providers::anthropic`), which places markers on the last tool, the last system block, and the final message so a growing tool loop reuses the previous iteration's cache rather than only the system prompt. The one exception is text mode (`native_tools = false`, prompt-guided tools), which only the Chat Completions adapter implements and which keeps the compat client, and so keeps paying full price.
- **OpenRouter forwards markers to Anthropic and Gemini** but adds none itself; hosted OpenAI rejects unknown content-part fields. The OpenRouter slug (and any endpoint on `openrouter.ai`) enables `OpenAiModel::with_explicit_cache_control`, which marks the last system and last user message; every other Chat Completions endpoint stays unmarked.
@@ -423,26 +423,26 @@ A single agent that knows everything also has a system prompt the size of a smal
Each archetype lives under `agents/<name>/` with an `agent.toml` (metadata, tool scope, model hint) and a prompt. The orchestrator's chat delegates are the ones in its `[subagents]` allowlist:
-| Archetype | When the orchestrator picks it |
-| -------------------- | --------------------------------------------------------------------------------------------- |
-| `orchestrator` | The Master Agent: top-level, direct-capable default. Never spawned by another orchestrator. |
-| `task_manager_agent` | Adding, previewing, fetching, updating or removing task sources, workflow bundles, artifacts. |
-| `vision_agent` | Anything that depends on the content of an image (describe, OCR, UI elements). |
-| `image_agent` | Generating or editing an image. |
-| `video_agent` | Generating a video or animating an image. |
-| `presentation_agent` | Building a slide deck with grounding and citations (feature `documents`). |
-| `skill_setup` | Finding, installing and managing skills from registries (`setup_skills`). |
-| `workflow_builder` | Authoring or editing a saved workflow (`build_workflow`); returns a proposal, never saves. |
-| `flow_discovery` | Suggesting workflows worth setting up (`discover_workflows`). |
+| Archetype | When the orchestrator picks it |
+| ---------------------- | ---------------------------------------------------------------------------------------------- |
+| `orchestrator` | The Master Agent: top-level, direct-capable default. Never spawned by another orchestrator. |
+| `task_manager_agent` | Adding, previewing, fetching, updating or removing task sources, workflow bundles, artifacts. |
+| `vision_agent` | Anything that depends on the content of an image (describe, OCR, UI elements). |
+| `image_agent` | Generating or editing an image. |
+| `video_agent` | Generating a video or animating an image. |
+| `presentation_agent` | Building a slide deck with grounding and citations (feature `documents`). |
+| `skill_setup` | Finding, installing and managing skills from registries (`setup_skills`). |
+| `workflow_builder` | Authoring or editing a saved workflow (`build_workflow`); returns a proposal, never saves. |
+| `flow_discovery` | Suggesting workflows worth setting up (`discover_workflows`). |
Other built-ins are never chat delegates:
-| Archetype | Who runs it |
-| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
-| `planner`, `critic` | Only the `parallel_research_cross_check` workflow-run template (decompose and research = `planner`, cross_check = `critic`). |
-| `summarizer` | The harness, to compress oversized tool results; also the synthesize phase of that workflow-run template. |
-| `trigger_triage` / `trigger_reactor` | Classifying an incoming external event, and the lightweight reaction to one. |
-| `morning_briefing` | Cron: the daily digest, on a named read-only tool belt. |
+| Archetype | Who runs it |
+| -------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
+| `planner`, `critic` | Only the `parallel_research_cross_check` workflow-run template (decompose and research = `planner`, cross_check = `critic`). |
+| `summarizer` | The harness, to compress oversized tool results; also the synthesize phase of that workflow-run template. |
+| `trigger_triage` / `trigger_reactor` | Classifying an incoming external event, and the lightweight reaction to one. |
+| `morning_briefing` | Cron: the daily digest, on a named read-only tool belt. |
Work that used to go to single-belt specialists (coding, crypto, settings, scheduling, product docs, MCP servers) is now done by the orchestrator itself through **inline skills**: `use_skill` loads a tool pack's guide and schemas (`coding`, `web3`, `system`, `scheduling`, `docs`, `mcp`), and the same tools are `Deferred` so `tool_search` finds any single one. Running an installed skill is the orchestrator's own `run_workflow`. See [`tools/toolpacks/README.md`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/tools/toolpacks/README.md).
@@ -489,11 +489,11 @@ Primary (direct-capable, Master Agent on `coding` hint)
Each `AgentDefinition` carries an `agent_tier` field (`chat` / `reasoning` / `worker`, default `worker`). The contract:
-| Tier | May spawn | Must NOT spawn | Typical members |
-| ----------- | --------------------- | ------------------------------- | ------------------------------------------ |
-| `chat` | `reasoning`, `worker` | another `chat` | `orchestrator` |
-| `reasoning` | `worker` | another `reasoning`, any `chat` | `planner` (today the canonical one) |
-| `worker` | nothing[^1] | anything | critic, image_agent, task_manager_agent, … |
+| Tier | May spawn | Must NOT spawn | Typical members |
+| ----------- | --------------------- | ------------------------------- | ------------------------------------------------------------------------------- |
+| `chat` | `reasoning`, `worker` | another `chat` | `orchestrator` |
+| `reasoning` | `worker` | another `reasoning`, any `chat` | `planner` (today the canonical one) |
+| `worker` | nothing[^1] | anything | critic, image_agent, task_manager_agent, … |
[^1]: Skill-wildcard entries (`{ skills = "*" }`) are exempt because they name no agent: they expand to the connected Composio actions as `Deferred` tools the agent reaches through `tool_search`, not to a spawn.
@@ -662,24 +662,24 @@ None of these change the loop's shape - they just make the common failure modes
The harness shell lives under `crates/openhuman-core/src/agent/`, with the tinyagents adapter seam in `crates/openhuman-core/src/agent/tinyagents/` and archetype definitions in `crates/openhuman-core/src/agent/registry/`. The README in `crates/openhuman-core/src/agent/` enumerates the public surface; the most load-bearing files (paths relative to `crates/openhuman-core/src/agent/` unless prefixed) are:
-| File / dir | What lives there |
-| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `session_host/runtime_session.rs` | `Agent::turn` - the lifecycle described above; routes into the tinyagents runner via `tinyagents/turn_runner.rs`. |
-| `tinyagents/mod.rs` | `run_turn_via_tinyagents_shared` - the shared tinyagents harness assembly (the live loop). |
-| `tinyagents/middleware.rs` | The named OpenHuman middleware stack (approval/security, tool policy, recovery, budgets, circuit breaker). |
-| `harness/graph.rs` | The channel/CLI bus turn route into the tinyagents runner. |
-| `subagent_host/` | Direct OpenHuman planner/executor/persistence adapters for `tinyagents-orchestration::subagent`; product prompt/tool/model/security/artifact/progress behavior remains here. |
-| `orchestration/subagent_sessions/` | Durable reusable sub-agent identity, compatibility matching, persisted status/history. |
-| `harness/definition.rs` | `AgentDefinition` - what an archetype declares. |
-| `subagent_host/ops/runner.rs` | Integration-tool ranking and the host execution leaf; generic lifecycle stays in `tinyagents-orchestration`. |
-| `tinyagents/payload_summarizer.rs` | The model call behind TinyJuice's oversized-tool-result summary. |
-| `session_host/tool_progress.rs` | Surviving OpenHuman seam: `TurnProgress`. |
-| `message_convert.rs` | Concrete durable/provider conversion around canonical tool-call dialect APIs. |
-| `triage/` | External-trigger classification + escalation. |
-| `registry/agents/` | Built-in archetypes - one subdirectory per agent. |
-| `hooks.rs` / `stop_hooks.rs` | Post-turn and mid-turn hook surfaces. |
-| `cost.rs` | Per-turn USD/token accounting. |
-| `progress.rs` | Real-time progress events to the UI. |
+| File / dir | What lives there |
+| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
+| `session_host/runtime_session.rs` | `Agent::turn` - the lifecycle described above; routes into the tinyagents runner via `tinyagents/turn_runner.rs`. |
+| `tinyagents/mod.rs` | `run_turn_via_tinyagents_shared` - the shared tinyagents harness assembly (the live loop). |
+| `tinyagents/middleware.rs` | The named OpenHuman middleware stack (approval/security, tool policy, recovery, budgets, circuit breaker). |
+| `harness/graph.rs` | The channel/CLI bus turn route into the tinyagents runner. |
+| `subagent_host/` | Direct OpenHuman planner/executor/persistence adapters for `tinyagents-orchestration::subagent`; product prompt/tool/model/security/artifact/progress behavior remains here. |
+| `orchestration/subagent_sessions/` | Durable reusable sub-agent identity, compatibility matching, persisted status/history. |
+| `harness/definition.rs` | `AgentDefinition` - what an archetype declares. |
+| `subagent_host/ops/runner.rs` | Integration-tool ranking and the host execution leaf; generic lifecycle stays in `tinyagents-orchestration`. |
+| `tinyagents/payload_summarizer.rs` | The model call behind TinyJuice's oversized-tool-result summary. |
+| `session_host/tool_progress.rs` | Surviving OpenHuman seam: `TurnProgress`. |
+| `message_convert.rs` | Concrete durable/provider conversion around canonical tool-call dialect APIs. |
+| `triage/` | External-trigger classification + escalation. |
+| `registry/agents/` | Built-in archetypes - one subdirectory per agent. |
+| `hooks.rs` / `stop_hooks.rs` | Post-turn and mid-turn hook surfaces. |
+| `cost.rs` | Per-turn USD/token accounting. |
+| `progress.rs` | Real-time progress events to the UI. |
## Agent state graphs (`agent_graph`): HISTORICAL (removed)
@@ -716,8 +716,8 @@ StateGraph::new(name)
| `hitl/` | Human-in-the-loop: `approval`/`clarification` interrupt builders + `ApplyResume` (folds the human's answer into state on resume). A node returns `Command::Interrupt` to pause. |
| `observability/` | `EventBusSink` (a `ProgressSink`) emits `tracing` spans + publishes the `GraphRun*`/`GraphNode*` `DomainEvent` family (new `agent_graph` event domain). |
| `summarization/` | Node-boundary wrapper over `context::summarize_chat_history`. |
-| `memory/` | Pre-node wrapper for memory context. |
-| `definitions/` | Built-in graphs over a shared `ProductState`: `canonical_turn` (the agent turn as a `dispatch → parse → stop_check → tools → compact → loop / finalize` graph) and `plan_execute_review` (composes the `planner` with a worker archetype around a HITL review gate), plus a deterministic `demo_review` twin for tests. A registry (`list_definitions`/`build_definition`) + `runner` (`run_graph`/`resume_graph`) persist runs to the checkpointer and emit bus events. |
+| `memory/` | Pre-node wrapper for memory context. |
+| `definitions/` | Built-in graphs over a shared `ProductState`: `canonical_turn` (the agent turn as a `dispatch → parse → stop_check → tools → compact → loop / finalize` graph) and `plan_execute_review` (composes the `planner` with a worker archetype around a HITL review gate), plus a deterministic `demo_review` twin for tests. A registry (`list_definitions`/`build_definition`) + `runner` (`run_graph`/`resume_graph`) persist runs to the checkpointer and emit bus events. |
| `blueprint/` | The per-agent chain type. Every built-in agent declares its LangGraph-compatible chain in a `graph.rs` next to `prompt.rs` (`pub fn graph() -> GraphBlueprint`), wired into `BuiltinAgent.graph_fn`. `GraphBlueprint` is serializable (typed `NodeKind`/`EdgeSpec`), structurally validated, and `compile()`s to a real `CompiledGraph`. Reusable shapes: `canonical_turn` (most agents), `single_shot`, `orchestrator`, `plan_execute_review`. Inspect via `openhuman.agent_graph_{agent_list,agent_graph}`. |
### Per-agent graphs (`graph.rs`)
@@ -739,13 +739,13 @@ session/turn host, while a sub-agent call enters `agent/subagent_host` and its
direct `tinyagents-orchestration::subagent` lifecycle. There is no
`harness/subagent_runner` compatibility path. The surrounding OpenHuman seam:
-| File (`crates/openhuman-core/src/agent/tinyagents/`) | Role |
-| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `mod.rs` | The runner (`run_turn_via_tinyagents_shared`): installs the native `ChatModel`, host tool adapters, and middleware on an `AgentHarness`; runs one turn; caps output through `MaxTokensModel` (`agent/tinyagents/model.rs`); mirrors progress; forwards steering; and pauses gracefully at the model-call cap. |
-| `mod.rs` / `model.rs` / `tools.rs` / `convert.rs` | `RunPolicy` / `ChatModel` / `Tool` / message adapters (incl. unknown-tool policy and out-of-band reasoning forwarding). |
-| `observability.rs` | Harness `AgentEvent` → `AgentProgress` + cost; `GraphTracingSink` for graph events. |
-| `orchestration.rs` | Re-exported `graph::orchestration` task-store types; map-reduce fanout now uses the TinyAgents SDK surface directly. |
-| `delegation.rs` | The durable `plan → execute ⇄ review → finalize` delegation graph (production worker wired in `orchestration::delegation`), checkpointed via TinyAgents 2.1's own `SqliteCheckpointer`. The earlier `SqlRunLedgerCheckpointer` adapter and its `checkpoint.rs` are retired. |
+| File (`crates/openhuman-core/src/agent/tinyagents/`) | Role |
+| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `mod.rs` | The runner (`run_turn_via_tinyagents_shared`): installs the native `ChatModel`, host tool adapters, and middleware on an `AgentHarness`; runs one turn; caps output through `MaxTokensModel` (`agent/tinyagents/model.rs`); mirrors progress; forwards steering; and pauses gracefully at the model-call cap. |
+| `mod.rs` / `model.rs` / `tools.rs` / `convert.rs` | `RunPolicy` / `ChatModel` / `Tool` / message adapters (incl. unknown-tool policy and out-of-band reasoning forwarding). |
+| `observability.rs` | Harness `AgentEvent` → `AgentProgress` + cost; `GraphTracingSink` for graph events. |
+| `orchestration.rs` | Re-exported `graph::orchestration` task-store types; map-reduce fanout now uses the TinyAgents SDK surface directly. |
+| `delegation.rs` | The durable `plan → execute ⇄ review → finalize` delegation graph (production worker wired in `orchestration::delegation`), checkpointed via TinyAgents 2.1's own `SqliteCheckpointer`. The earlier `SqlRunLedgerCheckpointer` adapter and its `checkpoint.rs` are retired. |
**Orchestration on graphs** (`crates/openhuman-core/src/agent/orchestration/`):