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
refactor(agent): replace the positional turn entry fns with TurnSpec
Steven Enamakel3c718b381ed0
diff --git a/crates/openhuman-core/src/agent/README.md b/crates/openhuman-core/src/agent/README.mdindex d179c60c78..e7c49caa95 100644--- a/crates/openhuman-core/src/agent/README.md+++ b/crates/openhuman-core/src/agent/README.md@@ -31,7 +31,7 @@ is adapters that hand TinyAgents the things only OpenHuman knows.v v+-----------------------------------------------------------------+| agent/tinyagents/ the adapter seam |- | run_root_turn_via_hosted_agent / run_turn_via_tinyagents_shared|+ | TurnSpec::run_hosted / TurnSpec::run|| TurnModelSource, middleware stack, host/ capability adapters, || OpenhumanEventBridge, journal |+-----------------------------------------------------------------+@@ -79,7 +79,7 @@ the bus path because they keep their own history.| v| run_chat_turn_graph session_host/turn/graph.rs| v- | run_root_turn_via_hosted_agent tinyagents/turn_exec.rs+ | TurnSpec::run_hosted tinyagents/turn_exec.rs| | TurnDriver::prepare: models + tools; install_turn_middleware| v| AgentHarness loop <---------------------------------+@@ -122,7 +122,7 @@ In order:history and the tool snapshot. The driver builds this turn's tiered`ChatModel` set from `TurnModelSource`, resolves the context window, andcalls `run_chat_turn_graph`, which calls- `run_root_turn_via_hosted_agent`.+ `TurnSpec::run_hosted`.6. `TurnDriver::prepare` plans the turn ([`tinyagents/turn_plan.rs`](./tinyagents/turn_plan.rs)) and `install_turn_middleware` ([`tinyagents/turn_middleware.rs`](./tinyagents/turn_middleware.rs)) registers themodels, the tools (through `CanonicalSharedToolAdapter`) and themiddleware stack: approval and security gating, tool policy, cost@@ -151,7 +151,7 @@ In order:The bus path is shorter. `bus.rs` scopes the origin, sandbox mode and filestate agent id, then calls `harness::run_channel_turn_via_graph`-([`harness/graph.rs`](./harness/graph.rs)), which calls `run_turn_via_tinyagents_shared`. There is+([`harness/graph.rs`](./harness/graph.rs)), which calls `TurnSpec::run`. There isno TinyAgents `Session`: the caller owns the history vector, and`ask_user_clarification` is an early-exit tool whose question becomes thereply.@@ -195,7 +195,7 @@ target `AgentDefinition` and call `subagent_host::run_subagent_with_parent`.vtinyagents-orchestration::subagent lifecyclev- run_turn_via_tinyagents_shared (subagent_host/ops/graph/dispatch.rs)+ TurnSpec::run (subagent_host/ops/graph/dispatch.rs)| child events -> Subagent* AgentProgress variants on parent channelvone compact tool_result back to the parent@@ -333,7 +333,7 @@ Persistence, setup and RPC:`register_agent_handlers` installs it at startup.- `TurnModelSource` ([`tinyagents/turn_models.rs`](./tinyagents/turn_models.rs)): builds a turn's primary,tier-routed and summarizer `ChatModel`s from `(role, config)`.-- `run_turn_via_tinyagents_shared` and `run_root_turn_via_hosted_agent`+- `TurnSpec::run` and `TurnSpec::run_hosted`([`tinyagents/turn_exec.rs`](./tinyagents/turn_exec.rs)): the only places a harness is invoked.- `OpenHumanRunContext` (`tinyagents/host/run_context.rs`): the explicitper-turn carrier (origin, progress, thread, workspace, cancellation, stopdiff --git a/crates/openhuman-core/src/agent/context/README.md b/crates/openhuman-core/src/agent/context/README.mdindex 1d01501d51..294e686b7f 100644--- a/crates/openhuman-core/src/agent/context/README.md+++ b/crates/openhuman-core/src/agent/context/README.md@@ -2,7 +2,7 @@Global context management for agent sessions: system-prompt assembly, per-session context bookkeeping (utilisation stats, budget configuration), and the shared microcompact constants. Agents hold one `ContextManager` per session. This is a **pure logic / state-tracking domain**: no RPC controllers, no agent tools, no event-bus subscribers, no persisted store.-> **Status (#4249): live history reduction/summarization moved out of this directory.** The in-turn compaction that used to live here (`ContextManager::reduce_before_call`, the `Summarizer` trait, `ProviderSummarizer`, `SegmentRecapSummarizer`, `microcompact.rs`, `pipeline.rs`, `guard.rs`) is gone: see [History](#history-4249). Folding an over-budget transcript into a summary now runs as the vendored `tinyagents_harness::middleware::ContextCompressionMiddleware` (with the seam-owned `ImageAwareMessageTrimMiddleware` as the deterministic backstop) inside `run_turn_via_tinyagents_shared` ([`agent/tinyagents/turn_exec.rs`](../tinyagents/turn_exec.rs)), backed by `agent/tinyagents/summarize.rs::ModelSummarizer`. Tool-result body clearing runs in `tinyagents_harness::middleware::MicrocompactMiddleware`. [`stats.rs`](./stats.rs) keeps the data model behind `ContextManager::stats()`.+> **Status (#4249): live history reduction/summarization moved out of this directory.** The in-turn compaction that used to live here (`ContextManager::reduce_before_call`, the `Summarizer` trait, `ProviderSummarizer`, `SegmentRecapSummarizer`, `microcompact.rs`, `pipeline.rs`, `guard.rs`) is gone: see [History](#history-4249). Folding an over-budget transcript into a summary now runs as the vendored `tinyagents_harness::middleware::ContextCompressionMiddleware` (with the seam-owned `ImageAwareMessageTrimMiddleware` as the deterministic backstop) inside `TurnSpec::run` ([`agent/tinyagents/turn_exec.rs`](../tinyagents/turn_exec.rs)), backed by `agent/tinyagents/summarize.rs::ModelSummarizer`. Tool-result body clearing runs in `tinyagents_harness::middleware::MicrocompactMiddleware`. [`stats.rs`](./stats.rs) keeps the data model behind `ContextManager::stats()`.## Responsibilitiesdiff --git a/crates/openhuman-core/src/agent/harness/README.md b/crates/openhuman-core/src/agent/harness/README.mdindex 093587c0f8..828319848f 100644--- a/crates/openhuman-core/src/agent/harness/README.md+++ b/crates/openhuman-core/src/agent/harness/README.md@@ -2,7 +2,7 @@Product shell around the tinyagents tool loop. The model/tool iterationitself runs in `crate::agent::tinyagents` (via-`run_turn_via_tinyagents_shared`); this module owns everything OpenHuman+`TurnSpec::run`); this module owns everything OpenHumanlayers on top: sub-agent definitions, parent/child context plumbing, post-turnmemory/archival hooks, and oversized-tool-result handling.@@ -41,7 +41,7 @@ used here (not defined here) by [`fork_context.rs`](./fork_context.rs).| --- | --- || [`host_definition.rs`](./host_definition.rs), [`builtin_definitions.rs`](./builtin_definitions.rs) | The host side of agent definitions: `AgentExt` (prompt omissions, TokenJuice profile, MCP flag, prompt builder) over `tinyagents_definition::AgentDefinition<X>`, plus `AgentDefinitionRegistry` (a `DefinitionSet<AgentExt>` with the process/context singleton) and user-definition path resolution. The vocabulary (`ModelSpec`, `ToolScope`, `SandboxMode`, `AgentTier`, `PromptSource`, ...) and the TOML directory loader live in `tinyagents-definition`. Built-ins come from `crate::agent::registry::agents`. || `fork_context.rs` | Parent-handle context for direct host dispatch. `fork_context.rs` also carries the `RunQueue` handle (from `tinyagents_harness::run_queue`) down to a forked turn. |-| `graph.rs` | `run_channel_turn_via_graph` (`pub(crate)`): the channel/CLI turn graph, thin over `run_turn_via_tinyagents_shared`; called by the `agent.run_turn` native-bus handler in [`agent/bus.rs`](../bus.rs). |+| `graph.rs` | `run_channel_turn_via_graph` (`pub(crate)`): the channel/CLI turn graph, thin over `TurnSpec::run`; called by the `agent.run_turn` native-bus handler in [`agent/bus.rs`](../bus.rs). || `artifact_offload/` | The `outputs/` / `workspace/` convention under `action_dir`: prompt half (`contract.rs`) and host policy half (`policy.rs`); mechanics (thresholds, path resolution, pointer rendering, the writer) live in `tinyagents_harness::artifacts` and are re-exported here. || `tool_result_artifacts/` | Wiring only: `new_tool_result_store` hands `tinyagents_harness::artifacts::tool_results` OpenHuman's redactor (`SanitizingRedactor`), `file_read`/`use_skill` names and `FileReadTool::MAX_FILE_SIZE_BYTES`. The store, `[tool_result_preview]` envelope, budgets and paged reads live in the crate. || `required_output.rs` | Pure validate/repair/synthesize primitives (issue #4117) that guarantee a required structured-output block (for example a `thoughts` JSON block) on every accepted turn. The orchestration that calls these lives on the session in [`../session_host/turn/`](../session_host/turn/). |@@ -71,7 +71,7 @@ turn lifecycle are in `../session_host/`; `run_subagent`,## Dependencies- `tinyagents_harness` (vendored via [`vendor/tinyagents/`](../../../../../vendor/tinyagents/)): the tool loop- itself (`run_turn_via_tinyagents_shared`), the `run_queue` and `artifacts`+ itself (`TurnSpec::run`), the `run_queue` and `artifacts`primitives this module wraps, and the `InMemoryStore` used as thetool-result artifact index.- `tinytools_agent` (also vendored): the tool-call parsers themselvesdiff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents.rsindex b879b636d9..9774538ee9 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents.rs@@ -9,7 +9,7 @@//! [`DetachedTaskRegistry`](tinyagents_tasks::DetachedTaskRegistry),//! keyed by its `task_id`, with://! - an `Arc<RunQueue>` — the same steering channel the steering forwarder in-//! `run_turn_via_tinyagents_shared` drains mid-turn, so `steer_subagent` can+//! `TurnSpec::run` drains mid-turn, so `steer_subagent` can//! inject a message when no crate-native steering handle is registered;//! - a TinyAgents `SteeringHandle` in the process-local//! `SteeringRegistry` while the child TinyAgents run is active, sodiff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rsindex 1816300837..6dc2bc5fba 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs@@ -5,7 +5,7 @@//! Each running async sub-agent registers here (via [`register`]), keyed by//! its `task_id`, with://! - an `Arc<RunQueue>` — the same steering channel the steering forwarder in-//! `run_turn_via_tinyagents_shared` drains mid-turn, so `steer_subagent` can+//! `TurnSpec::run` drains mid-turn, so `steer_subagent` can//! inject a message when no crate-native steering handle is registered;//! - a TinyAgents `SteeringHandle` in the process-local//! `SteeringRegistry` while the child TinyAgents run is active, sodiff --git a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rsindex bfc2ff38d5..60a2ebfee4 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs@@ -3,7 +3,7 @@//! Pairs with `spawn_async_subagent`: that tool returns a `task_id` for a child//! running in the background. `steer_subagent` pushes a message into that child's//! steering queue, which the steering forwarder in the child's turn-//! (`run_turn_via_tinyagents_shared`) drains mid-flight — so the parent can+//! (`TurnSpec::run`) drains mid-flight — so the parent can//! redirect or feed data to a running sub-agent//! without waiting for it to finish or restarting it. Mirrors Codex `send_input`.diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rsindex ecd8724206..64c43c5ca5 100644--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs@@ -13,7 +13,7 @@//! definition asks to omit (`omit_identity`, `omit_memory_context`,//! `omit_safety_preamble`).//! 5. Runs the child turn on the TinyAgents harness (`ops::graph` →-//! [`crate::agent::tinyagents::run_turn_via_tinyagents_shared`]) using+//! [`crate::agent::tinyagents::TurnSpec::run`]) using//! the parent's [`crate::inference::provider::Provider`], then//! mirrors the child transcript/progress and returns one compact tool result//! to the parent.diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rsindex 0baa3476c4..425d6e9186 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs@@ -178,7 +178,7 @@ pub(in super::super) async fn run_subagent_via_graph(// A sub-agent turn runs *nested inside* the parent agent's turn (parent// harness → spawn_subagent tool → here), so the child's full- // `run_turn_via_tinyagents_shared` future would otherwise sit on the parent's+ // `TurnSpec::run` future would otherwise sit on the parent's// poll stack. Heap-allocate it (as the legacy `run_inner_loop` did) so the// parent+child harness drives don't overflow the stack.// Native-tool support drives the durable-history suffix dispatcher; capture itdiff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex 0ad6dde952..791fa65db8 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -121,7 +121,7 @@ pub(crate) async fn run_subagent_direct(// every caller doesn't have to carry this future's state inline.// Tools that delegate run inside the parent agent's already-deep// turn poll (the boxed tinyagents harness drive future in- // `run_turn_via_tinyagents_shared`), so the parent's stack would+ // `TurnSpec::run`), so the parent's stack would// otherwise pile (parent turn state + dispatch_subagent state +// run_subagent's wrapper state + run_typed_mode state + child turn// state) onto tokio's 2 MiB worker stack and abort with "thread@@ -299,7 +299,7 @@ pub(crate) async fn run_subagent_direct(// When the worker opted into git-worktree isolation, its isolated// checkout is carried on the `WorkspaceDescriptor` prepared below and// threaded onto the run's tinyagents `RunContext`- // (`run_turn_via_tinyagents_shared` → `RunContext::with_workspace`).+ // (`TurnSpec::run` → `RunContext::with_workspace`).// Every tool call then receives it via// `ToolExecutionContext::from_run_context`, so acting tools (shell, git)// resolve their CWD to that worktree (`effective_action_dir_for_context`)diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rsindex 8e702e5232..2614b02570 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs@@ -237,7 +237,7 @@ async fn run_queue_steer_lands_in_subagent_history() {// End-to-end proof that flipping the subagent loop's run-queue arg from// `None` to `Some(queue)` wires steering all the way through: a message// pushed to the queue before the run is drained by the steering forwarder- // in the child's turn (`run_turn_via_tinyagents_shared`) and appears as a+ // in the child's turn (`TurnSpec::run`) and appears as a// `[User steering message]:` user turn in the exact request sent to the// provider. This is the mechanism behind the `steer_subagent` tool.let provider = ScriptedProvider::new(vec![text_response("acknowledged")]);diff --git a/crates/openhuman-core/src/agent/tinyagents/README.md b/crates/openhuman-core/src/agent/tinyagents/README.mdindex 3670be845c..5966160e2c 100644--- a/crates/openhuman-core/src/agent/tinyagents/README.md+++ b/crates/openhuman-core/src/agent/tinyagents/README.md@@ -1,6 +1,6 @@# tinyagents-The adapter seam between OpenHuman and the vendored [`tinyagents`](../../../../../vendor/tinyagents/) crate family (issue #4249). Every agent turn runs on the crate's `AgentHarness` loop; this module bridges OpenHuman's `Provider`, `Tool`, and `TranscriptMessage` row types onto the crate's `ChatModel`, `Tool`, and `Message` traits, assembles the per-turn harness, and enforces OpenHuman-specific policy (approval, tool scope, budgets, credential scrubbing, compaction) as harness middleware on the way in and out. The chat, channel/CLI, and sub-agent routes all enter through one function, `run_turn_via_tinyagents_shared`, so they cannot drift from each other.+The adapter seam between OpenHuman and the vendored [`tinyagents`](../../../../../vendor/tinyagents/) crate family (issue #4249). Every agent turn runs on the crate's `AgentHarness` loop; this module bridges OpenHuman's `Provider`, `Tool`, and `TranscriptMessage` row types onto the crate's `ChatModel`, `Tool`, and `Message` traits, assembles the per-turn harness, and enforces OpenHuman-specific policy (approval, tool scope, budgets, credential scrubbing, compaction) as harness middleware on the way in and out. The chat, channel/CLI, and sub-agent routes all enter through one function, `TurnSpec::run`, so they cannot drift from each other.## Responsibilities@@ -18,14 +18,14 @@ The adapter seam between OpenHuman and the vendored [`tinyagents`](../../../../.| File / group | Role || --- | --- |-| [`mod.rs`](./mod.rs) | Module root: declares submodules and re-exports (`TurnContextMiddleware`, `TranscriptSnapshotSink`, `SubagentScope`, `ToolPolicyEnforcement`, `TinyagentsTurnOutcome`, `TurnModelSource`/`TurnModels`, `run_turn_via_tinyagents_shared`). |+| [`mod.rs`](./mod.rs) | Module root: declares submodules and re-exports (`TurnContextMiddleware`, `TranscriptSnapshotSink`, `SubagentScope`, `ToolPolicyEnforcement`, `TinyagentsTurnOutcome`, `TurnModelSource`/`TurnModels`, `TurnSpec::run`). || [`turn_policy.rs`](./turn_policy.rs) | `ToolPolicyEnforcement`, provider locality and the `OPENHUMAN_*` overrides feeding `tinyagents_harness::turn_policy::run_policy`. |-| `turn_runner.rs` | `run_turn_via_tinyagents_shared`, the single entry point every production caller uses, plus the `#[cfg(test)]`-only `run_turn_via_tinyagents`. |+| `turn_runner.rs` | `TurnSpec::run`, the single entry point every production caller uses, plus the `#[cfg(test)]`-only `run_turn_via_tinyagents`. || `turn_models.rs` | `TurnModels` (primary + tier routes + summarizer) and `TurnModelSource`, whose `build`/`build_summarizer` construct crate-native models from `(role, config)` via `build_turn_models_crate`. || `harness_assembly.rs` | `assemble_turn_harness`, which registers models, tools, and middleware in order. || [`harness_tool_registration.rs`](./harness_tool_registration.rs) | Tool + agent capability-registry projection consumed by `assemble_turn_harness`. || [`turn_outcome.rs`](./turn_outcome.rs) | `TinyagentsTurnOutcome` and `record_unobserved_turn_usage` (the `HaltSummarySlot`, `ToolOutcomeSink` and `ToolCallOutcome` types are `tinyagents_harness::turn_outcome`'s), the cost-tracker fallback for turns with no `on_progress` observer. |-| [`turn_run_error.rs`](./turn_run_error.rs) | Maps a failed harness run onto the typed OpenHuman error `run_turn_via_tinyagents_shared` returns. |+| [`turn_run_error.rs`](./turn_run_error.rs) | Maps a failed harness run onto the typed OpenHuman error `TurnSpec::run` returns. || [`turn_run_finalize.rs`](./turn_run_finalize.rs) | Turns a completed harness run into a `TinyagentsTurnOutcome` on the success path (journal completion, compaction diagnostics, the terminal `TurnCompleted` event). || `discovery/` | `install_tool_ranker` / `installed_tool_ranker`: the process-wide slot for the host's `ToolRanker` (a decision model such as Jev, installed by `openhuman-tinyhumans`; the core itself installs none), and `discovery_policy`, which turns the installed ranker plus `agent.tool_search` config into the `ToolDiscoveryPolicy` every turn harness runs with. A ranker that fails at search time falls back to BM25 in the harness. || `host/` | OpenHuman's implementations of the crate's ten host-capability traits: `agent_memory`, `budget_gate`, `context_composer`, `definition_registry`, `experience_store`, `learning_sink`, `model_resolver`, `progress_sink`, `security_gate`, `tool_outcome_classifier`. Each file adapts one trait onto the OpenHuman domain that implements it. |@@ -76,7 +76,7 @@ Most of the module is `pub(crate)` or private. The `pub` items, per `mod.rs`:- `routes::ResolvedRouteMiddleware`: records canonical response metadata in the explicit run context; `TinyagentsTurnOutcome` carries it to the bus.- `todos::*`, `host::*` (all ten `OpenHuman*` adapter structs), and `TurnModelSource`.-Within the crate the entry point is `run_turn_via_tinyagents_shared` (`pub(crate)`); `run_turn_via_tinyagents` is `#[cfg(test)]` only.+Within the crate the entry point is `TurnSpec::run` (`pub(crate)`); `run_turn_via_tinyagents` is `#[cfg(test)]` only.## RPC (`replay/`)@@ -101,7 +101,7 @@ Responses project the crate's own `AgentObservation` and `HarnessRunStatus` serd## Used by-- [`agent/session_host/turn/graph.rs`](../session_host/turn/graph.rs): the chat-turn route into `run_turn_via_tinyagents_shared`.+- [`agent/session_host/turn/graph.rs`](../session_host/turn/graph.rs): the chat-turn route into `TurnSpec::run`.- [`agent/harness/graph.rs`](../harness/graph.rs): the channel/CLI bus turn route.- [`agent/subagent_host/`](../subagent_host/): the sub-agent spawn route. It and the session route both build their context-window summarizer through `TurnModelSource::build_summarizer`.- [`agent/session_host/builder/setters.rs`](../session_host/builder/setters.rs), `agent/subagent_host/ops/{provider,runner}.rs`, `channels/`: construct `TurnModelSource`.@@ -129,7 +129,7 @@ through the typed parent run.- The taint/scope/redaction/approval/budget guarantees the crate deliberately does not know about are enforced in `host/` and `middleware*.rs`. Widening a permission or dropping a scope filter to make an adapter signature fit would silently disable a guarantee the rest of the system assumes.- `journal.rs` is best-effort: store opening and every write swallow errors behind a `[journal]` log line rather than failing a turn. `reaper.rs` logs its sweep under `[agent] startup run sweep`.-- `defer_turn_completed_to_caller` (a `run_turn_via_tinyagents_shared` parameter, issue #4457) exists because the chat/session path emits its own `TurnCompleted` after streaming a post-run checkpoint; callers without that step (channel/CLI) pass `false` and rely on this seam's emit.+- `defer_turn_completed_to_caller` (a `TurnSpec::run` parameter, issue #4457) exists because the chat/session path emits its own `TurnCompleted` after streaming a post-run checkpoint; callers without that step (channel/CLI) pass `false` and rely on this seam's emit.- [docs/gitbooks/en/developing/architecture/agent-harness.md](../../../../../docs/gitbooks/en/developing/architecture/agent-harness.md) is the narrative overview of the turn lifecycle and where this seam sits in it.## Further readingdiff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rsindex ae39e58fc9..04435a05d6 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rs@@ -1,5 +1,5 @@//! Map a failed `tinyagents` harness run onto the typed OpenHuman error the-//! caller expects, for [`run_turn_via_tinyagents_shared`](super::run_turn_via_tinyagents_shared).+//! caller expects, for [`TurnSpec::run`](TurnSpec::run).use crate::agent::tinyagents::journal::TurnJournal;use tinyagents_harness::turn_run_error::{classify_run_failure, RunFailureKind};diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rsindex 6515a461ca..8b9e310905 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs@@ -1,5 +1,5 @@//! Turn a completed `tinyagents` harness run into a-//! [`TinyagentsTurnOutcome`], for [`run_turn_via_tinyagents_shared`](super::turn_exec::run_turn_via_tinyagents_shared).+//! [`TinyagentsTurnOutcome`], for [`TurnSpec::run`](super::TurnSpec::run).//!//! Split out of the runner: everything here executes only on the success path//! (after the drive future returns `Ok`), covering journal completion,diff --git a/crates/openhuman-core/src/agent/tools/README.md b/crates/openhuman-core/src/agent/tools/README.mdindex 498571347f..926f73a5be 100644--- a/crates/openhuman-core/src/agent/tools/README.md+++ b/crates/openhuman-core/src/agent/tools/README.md@@ -27,7 +27,7 @@ instead of registering them as disabled.- `AskClarificationTool` returns the question text as its own tool output; itdoes not pause anything by itself. The pause happens because callers list`ask_user_clarification` in the harness seam's `early_exit_tools`- (`tinyagents::run_turn_via_tinyagents_shared`), and a successful call there+ (`tinyagents::TurnSpec::run`), and a successful call theresteers the loop to `Pause` instead of feeding the result back to the model.Any caller that exposes this tool without that listing gets a tool thatanswers its own question, since the model reads a normal success and keepsdiff --git a/crates/openhuman-core/src/agent/triage/evaluator.rs b/crates/openhuman-core/src/agent/triage/evaluator.rsindex 9acb4ccf0e..a696bc90ff 100644--- a/crates/openhuman-core/src/agent/triage/evaluator.rs+++ b/crates/openhuman-core/src/agent/triage/evaluator.rs@@ -23,7 +23,7 @@//! ## Why the turn path doesn't care about `tools_registry = []`//!//! The triage agent has `named = []` in its TOML (zero tools). The-//! tinyagents-backed turn path (`run_turn_via_tinyagents_shared` in+//! tinyagents-backed turn path (`TurnSpec::run` in//! `crates/openhuman-core/src/agent/tinyagents/mod.rs`) handles an empty registry by simply//! sending no tool schemas to the backend — the turn degrades to a plain//! chat completion.diff --git a/crates/openhuman-core/src/agent/triage/routing.rs b/crates/openhuman-core/src/agent/triage/routing.rsindex 5588cef5d5..c13267fec5 100644--- a/crates/openhuman-core/src/agent/triage/routing.rs+++ b/crates/openhuman-core/src/agent/triage/routing.rs@@ -27,7 +27,7 @@ pub struct ResolvedProvider {/// Kept for telemetry / observability compat with the previous two-path design.pub provider_name: String,/// Model identifier — the concrete string the turn- /// (`run_turn_via_tinyagents_shared`) will hand to the provider.+ /// (`TurnSpec::run`) will hand to the provider.pub model: String,/// Always `false` — local AI is never used for triage./// Preserved so existing telemetry subscribers that read this field do notdiff --git a/docs/gitbooks/en/developing/architecture/agent-harness.md b/docs/gitbooks/en/developing/architecture/agent-harness.mdindex cc5df41ce5..09256dcf1b 100644--- a/docs/gitbooks/en/developing/architecture/agent-harness.md+++ b/docs/gitbooks/en/developing/architecture/agent-harness.md@@ -93,7 +93,7 @@ Some settings remain runtime-wide for every agent (the live autonomy policy'sconfig sub-agents re-read); the crate README lists them under "Stillruntime-wide".-Every agent turn runs through the published [`tinyagents`](https://crates.io/crates/tinyagents) harness. There are three entry points: `Agent::turn`, the channel and CLI bus path, and `run_subagent`. All of them go through the adapter seam in [`crates/openhuman-core/src/agent/tinyagents/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-core/src/agent/tinyagents) (`run_turn_via_tinyagents_shared`). Context trimming is `MessageTrimMiddleware`, and cancellation is the tinyagents steering channel. Policy stop hooks (budget, thread-goal and iteration caps) fire through a `StopHookMiddleware` ([`tinyagents/stop_hooks.rs`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs)) that pauses the run on the first stop vote. The channel route forwards live `AgentProgress` like the chat route. The shared `TurnProgress` seam lives in `agent/session_host/tool_progress.rs`.+Every agent turn runs through the published [`tinyagents`](https://crates.io/crates/tinyagents) harness. There are three entry points: `Agent::turn`, the channel and CLI bus path, and `run_subagent`. All of them go through the adapter seam in [`crates/openhuman-core/src/agent/tinyagents/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-core/src/agent/tinyagents) (`TurnSpec::run`). Context trimming is `MessageTrimMiddleware`, and cancellation is the tinyagents steering channel. Policy stop hooks (budget, thread-goal and iteration caps) fire through a `StopHookMiddleware` ([`tinyagents/stop_hooks.rs`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs)) that pauses the run on the first stop vote. The channel route forwards live `AgentProgress` like the chat route. The shared `TurnProgress` seam lives in `agent/session_host/tool_progress.rs`.Multi-agent orchestration runs on the tinyagents graph layer, through `tinyagents-orchestration`'s `parallel` module, the host `spawn_parallel` adapter and the shared `graph::orchestration` `TaskStore` lifecycle primitives re-exported from [`orchestration/mod.rs`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/agent/orchestration/mod.rs):@@ -213,7 +213,7 @@ The loader is `agent::prompts::agents_md` (pure functions returning pre-loaded s## The tool-call loop-Inside `Agent::turn`, the tool-call loop is the inner engine. It is the published tinyagents crate's `AgentHarness` loop, assembled per turn by `run_turn_via_tinyagents_shared` ([`crates/openhuman-core/src/agent/tinyagents/mod.rs`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/agent/tinyagents/mod.rs)). It runs up to the turn's iteration cap, resolved in `session_host/builder/iteration_cap.rs`: an explicit `[agent] max_tool_iterations_override` (or `OPENHUMAN_AGENT_MAX_TOOL_ITERATIONS`) wins, then the agent definition's cap (the orchestrator's is 200), then `max_tool_iterations` (default 10) for a turn with no definition. The model is told how many calls remain at 50% and 80% of the budget, and `inference_agent_chat` reports a capped turn with `hit_cap: true` and its `checkpoint` text:+Inside `Agent::turn`, the tool-call loop is the inner engine. It is the published tinyagents crate's `AgentHarness` loop, assembled per turn by `TurnSpec::run` ([`crates/openhuman-core/src/agent/tinyagents/mod.rs`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/agent/tinyagents/mod.rs)). It runs up to the turn's iteration cap, resolved in `session_host/builder/iteration_cap.rs`: an explicit `[agent] max_tool_iterations_override` (or `OPENHUMAN_AGENT_MAX_TOOL_ITERATIONS`) wins, then the agent definition's cap (the orchestrator's is 200), then `max_tool_iterations` (default 10) for a turn with no definition. The model is told how many calls remain at 50% and 80% of the budget, and `inference_agent_chat` reports a capped turn with `hit_cap: true` and its `checkpoint` text:```textloop {@@ -620,7 +620,7 @@ The harness shell lives under `crates/openhuman-core/src/agent/`, with the tinya| File / dir | What lives there || ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- || `session_host/runtime_session.rs` | `Agent::turn`: the lifecycle described above; routes into the tinyagents runner via `tinyagents/turn_exec.rs`. |-| `tinyagents/mod.rs` | `run_turn_via_tinyagents_shared`: the shared tinyagents harness assembly (the live loop). |+| `tinyagents/mod.rs` | `TurnSpec::run`: 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. |@@ -645,7 +645,7 @@ direct `tinyagents-orchestration::subagent` lifecycle. There is no| 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` | The runner (`TurnSpec::run`): 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 uses the TinyAgents SDK surface directly. |diff --git a/docs/gitbooks/en/developing/architecture/flows-on-tinyagents.md b/docs/gitbooks/en/developing/architecture/flows-on-tinyagents.mdindex fe4da4e83f..f42d0bcf4a 100644--- a/docs/gitbooks/en/developing/architecture/flows-on-tinyagents.md+++ b/docs/gitbooks/en/developing/architecture/flows-on-tinyagents.md@@ -174,7 +174,7 @@ A flow `agent` node names a registered agent kind through a trusted- A harness `AgentDefinition` exists: build a full harness `Agent`(`Agent::from_config_for_agent`) and run the node's request through`run_single`. That is the same entry the builder, scout and cron- jobs use, and internally it drives `run_turn_via_tinyagents_shared`+ jobs use, and internally it drives `TurnSpec::run`([`crates/openhuman-core/src/agent/tinyagents/mod.rs`](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-core/src/agent/tinyagents/mod.rs)) -the tinyagents `AgentHarness` tool-call loop. The definition's ToolScope,`sandbox_mode`, and `max_iterations` govern the inner turn.