The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(orchestration): document the harness completion router
Steven Enamakel3d77adc8367f
diff --git a/crates/openhuman-core/src/agent/orchestration/README.md b/crates/openhuman-core/src/agent/orchestration/README.mdindex 11dd3248c4..282c17fee3 100644--- a/crates/openhuman-core/src/agent/orchestration/README.md+++ b/crates/openhuman-core/src/agent/orchestration/README.md@@ -36,7 +36,8 @@ RPC/tool formatting, and OpenHuman's worktree policy.finished background results back into chat, and settling run-ledger rowsfrom the global bus regardless of the parent turn's lifecycle(`running_subagents*.rs`, `background_completions.rs`,- `background_delivery.rs`, `run_ledger_finalize.rs`). The delivery turn runs+ `completion_notice.rs`, `background_delivery.rs`,+ `run_ledger_finalize.rs`). The delivery turn runson the originating thread's cached chat session via`web_chat::run_system_turn_on_thread`, never on a throwaway host.- A shared root `ParentExecutionContext` builder for surfaces that spawn real@@ -84,9 +85,19 @@ RPC/tool formatting, and OpenHuman's worktree policy.steering, boot reconcile). The status type, wait, ledger helpers, roster andsession resolution live in `tinyagents_orchestration::subagent`(`DetachedSubagentStatus`, `wait_detached`, `SubagentIdentity`, ...).- `background_completions.rs` and- `background_delivery.rs` queue and idle-gated, debounced, batched delivery- of finished background runs back into chat; `run_ledger_finalize.rs` is the+ `background_completions.rs` is the host adapter over the harness+ `tinyagents_tasks::CompletionRouter` (one durable `JsonlCompletionStore` per+ workspace at `.openhuman/background_completions.jsonl`, parent key = chat+ thread id): the router owns the queue, dedupe, tombstones (collected inline,+ stopped, cancelled thread), attempt counting and give-up, so a completion that+ was never delivered is redelivered after a restart+ (`background_delivery::recover_on_boot`, wired next to the orphaned-task+ reconcile in `core/runtime/bootstrap.rs`). `completion_notice.rs` is the+ `<background_agent_*>` wording (a `CompletionFormatter`) and the+ `[BACKGROUND_DELIVERY_FAILED]` give-up notice. `background_delivery.rs` keeps+ the host policy: idle-gated, debounced (3s), batched delivery of finished+ background runs back into chat, the system turn, and the give-up writer fed by+ `mark_failed`. `run_ledger_finalize.rs` is theglobal-bus subscriber that settles ledger rows for runs that outlive theirspawning turn.- `fleet_tools.rs`: decides which fleet-control tools (`wait_subagent`,diff --git a/crates/openhuman-core/src/threads/README.md b/crates/openhuman-core/src/threads/README.mdindex d102720d12..d1d5c7bcac 100644--- a/crates/openhuman-core/src/threads/README.md+++ b/crates/openhuman-core/src/threads/README.md@@ -73,7 +73,7 @@ as one `run_to_completion` unit: a caller that drops the request cannot leavethe work half done. Deleting a thread removes it from the store, invalidatesany web-channel session bound to it, cancels the detached sub-agents itspawned (`agent::orchestration::running_subagents`) before discarding their-queued results (`background_completions`), then deletes its turn snapshots.+queued results (`background_completions`, which cancels the thread on the harness completion router), then deletes its turn snapshots.Purge does the same for every thread and calls the parse-independent`turn_state::store::clear_all`, so a corrupt snapshot file is removed too.diff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.mdindex 809f9e45ce..06c3ea5931 100644--- a/gitbooks/developing/architecture/agent-harness.md+++ b/gitbooks/developing/architecture/agent-harness.md@@ -418,7 +418,7 @@ neutral TinyAgents lifecycle:`wait_subagent` and `steer_subagent` accept either the durable `subagent_session_id` or the transient `task_id`; durable ids are preferred across turns. `list_subagents` shows reusable children for the current parent thread, and `close_subagent` marks a worker non-reusable and cancels it if it is still running. Inline blocking is explicit via `blocking: true`; it is no longer the default.-The synthesized archetype delegations (`delegate_*`, `build_workflow`, and the other `delegate_name` tools) follow the same contract: they route through the durable async path by default, returning an `[async_subagent_ref]` (with `subagent_session_id` + `task_id`) immediately, and the finished result is inserted into the parent chat as a new system turn via `background_completions`/`background_delivery`. The delivery turn persists its own closing message, `sender: "agent"`, id `agent:<run_id>`, `extraMetadata.requestId = run_id`, **before** it emits `chat_done` as `client_id: "system"`; the frontend reuses that id, so its usual `chat_done` append collapses onto the same row (the conversation store is idempotent for these deterministic `agent:`-prefixed ids; every other id is UUID-fresh and keeps the constant-time append path) instead of persisting the delivered result a second time (#5933). **Interactive turns follow the same contract since #6034**: `web_chat::presentation::deliver_response` stores the reply under `agent:<request_id>` before publishing `chat_done`, so an answer the core produced exists on disk whether or not a client is there to receive the announcement, a dropped socket or a reloaded webview costs a repaint, not the reply. The exception is a segmented delivery, where the client owns one row per segment and the core stores none; the frontend keeps generated ids there for exactly that reason. They fall back to inline blocking automatically when there is no parent agent turn or no chat thread to deliver into (cron/CLI), or when `blocking: true` is passed. Cross-turn continuity comes from three pieces: the per-turn `[active_subagents]` roster merges the live in-memory registry with the durable `subagent_sessions` store (so a cold-booted orchestrator still sees earlier workers); `continue_subagent` falls back from pause checkpoints to the durable store, resuming an idle worker with its persisted history; and a `workflow_proposal` payload found in a finished child's history is persisted as a parent-thread message (`extraMetadata.scope = "workflow_proposal"`) that the frontend rehydrates into the proposal card on thread load.+The synthesized archetype delegations (`delegate_*`, `build_workflow`, and the other `delegate_name` tools) follow the same contract: they route through the durable async path by default, returning an `[async_subagent_ref]` (with `subagent_session_id` + `task_id`) immediately, and the finished result is inserted into the parent chat as a new system turn via `background_completions`/`background_delivery`. The queue behind that is the harness `tinyagents_tasks::CompletionRouter` over a per-workspace `JsonlCompletionStore` (`.openhuman/background_completions.jsonl`, keyed by chat thread): it dedupes by task id, holds the tombstones for results the parent collected inline or that a Stop/delete cancelled, counts delivery attempts and hands back the records that gave up. A record stays leased until the delivery turn lands (`mark_delivered`), so a result that finished but was never delivered is redelivered after a restart. The host keeps the `<background_agent_*>` wording (a `CompletionFormatter`), the 3s idle debounce, the system turn and its web_chat events, and the writer that persists a given-up result into the thread. The delivery turn persists its own closing message, `sender: "agent"`, id `agent:<run_id>`, `extraMetadata.requestId = run_id`, **before** it emits `chat_done` as `client_id: "system"`; the frontend reuses that id, so its usual `chat_done` append collapses onto the same row (the conversation store is idempotent for these deterministic `agent:`-prefixed ids; every other id is UUID-fresh and keeps the constant-time append path) instead of persisting the delivered result a second time (#5933). **Interactive turns follow the same contract since #6034**: `web_chat::presentation::deliver_response` stores the reply under `agent:<request_id>` before publishing `chat_done`, so an answer the core produced exists on disk whether or not a client is there to receive the announcement, a dropped socket or a reloaded webview costs a repaint, not the reply. The exception is a segmented delivery, where the client owns one row per segment and the core stores none; the frontend keeps generated ids there for exactly that reason. They fall back to inline blocking automatically when there is no parent agent turn or no chat thread to deliver into (cron/CLI), or when `blocking: true` is passed. Cross-turn continuity comes from three pieces: the per-turn `[active_subagents]` roster merges the live in-memory registry with the durable `subagent_sessions` store (so a cold-booted orchestrator still sees earlier workers); `continue_subagent` falls back from pause checkpoints to the durable store, resuming an idle worker with its persisted history; and a `workflow_proposal` payload found in a finished child's history is persisted as a parent-thread message (`extraMetadata.scope = "workflow_proposal"`) that the frontend rehydrates into the proposal card on thread load.### Spawn hierarchy and tiers