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(tinyagents): update harness assembly references to turn plan and middleware
Steven Enamakel410a039cf03b
diff --git a/crates/openhuman-core/src/agent/README.md b/crates/openhuman-core/src/agent/README.mdindex 51264b68c7..925956a249 100644--- a/crates/openhuman-core/src/agent/README.md+++ b/crates/openhuman-core/src/agent/README.md@@ -79,8 +79,8 @@ 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_runner.rs- | | assemble_turn_harness: models + tools + middleware+ | run_root_turn_via_hosted_agent tinyagents/turn_exec.rs+ | | TurnDriver::prepare: models + tools; install_turn_middleware| v| AgentHarness loop <---------------------------------+| model call -> tool calls -> middleware -> results --+@@ -123,7 +123,7 @@ In order:`ChatModel` set from `TurnModelSource`, resolves the context window, andcalls `run_chat_turn_graph`, which calls`run_root_turn_via_hosted_agent`.-6. `assemble_turn_harness` ([`tinyagents/harness_assembly.rs`](./tinyagents/harness_assembly.rs)) registers the+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, costbudget, tool-output capping and summarization, credential scrubbing,@@ -334,7 +334,7 @@ Persistence, setup and RPC:- `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`- ([`tinyagents/turn_runner.rs`](./tinyagents/turn_runner.rs)): the only places a harness is invoked.+ ([`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, stophooks) passed into TinyAgents and down to recursive tools.diff --git a/crates/openhuman-core/src/agent/context/README.md b/crates/openhuman-core/src/agent/context/README.mdindex 54ac8a3ff6..1d01501d51 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_runner.rs`](../tinyagents/turn_runner.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 `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()`.## Responsibilities@@ -73,7 +73,7 @@ No `store.rs`. State is per-session and in-memory:## Used by- `agent::harness`: the primary consumer: `session/builder/builder_build.rs` constructs the `ContextManager`; `session/turn/core/harness_turn.rs` reads the budget/compaction getters into the tinyagents turn config; `session/turn/session_io/{transcript_persist,background_tasks}.rs` read `stats()`; `fork_context.rs` and [`../subagent_host/`](../subagent_host/) consume prompt types.-- `agent::tinyagents`: `harness_assembly.rs` reads `CLEARED_PLACEHOLDER` when configuring `MicrocompactMiddleware`; `payload_summarizer.rs` and `host/context_composer.rs` build `PromptContext`s through `agent::prompts`.+- `agent::tinyagents`: `turn_middleware.rs` reads `CLEARED_PLACEHOLDER` when configuring `MicrocompactMiddleware`; `payload_summarizer.rs` and `host/context_composer.rs` build `PromptContext`s through `agent::prompts`.- **`agent::registry::agents/*/prompt.rs`**, `flows/agents/*/prompt.rs`, `skills/*/agent/*/prompt.rs`: archetype prompt modules pull prompt sections/builder through `agent::prompts`.- `channels`: [`channels/system_prompt.rs`](../../channels/system_prompt.rs) (`ChannelSystemPrompt`, used by [`channels/runtime/startup/start_channels.rs`](../../channels/runtime/startup/start_channels.rs)) calls `channels_prompt::build_system_prompt_with_identity`; [`channels/mod.rs`](../../channels/mod.rs) re-exports `build_system_prompt`; the `channels/tests/*` prompt/identity tests call it directly.- `agent::triage`, `agent::debug`, `agent::orchestration::tools` (spawn_subagent and friends), `tools::orchestrator_tools`, `integrations::composio`: consume prompt types (`PromptContext`, `PromptSection`, `ToolCallFormat`, `ConnectedIntegration`, …) via `agent::prompts`.diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rsindex f5a582e016..db05480d79 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs@@ -171,7 +171,7 @@ impl OpenHumanHostBundleFactory {let models = Arc::new(OpenHumanModelResolver::new(Arc::clone(&inputs.config)));let budget = Arc::new(OpenHumanBudgetGate::new(Arc::clone(&inputs.config)));// The turn's live `AgentProgress` channel is fed by exactly one- // producer: `OpenhumanEventBridge`, which `turn_runner` subscribes to+ // producer: `OpenhumanEventBridge`, which `turn_exec` subscribes to// the run's `EventSink` on every turn and which carries what the UI// needs (iteration attribution, thinking, tool-argument fragments,// sub-agent scoping, cost). The harness also mirrors the loop onto thediff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rsindex 36407f8925..34863c7422 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs@@ -94,7 +94,7 @@ impl ApprovalSecurityMiddleware {/// Host side of the harness approval seam: the tool-set lookup, the global/// [`ApprovalGate`] hookup and the terminal audit row. The harness-/// `ApprovalGateMiddleware` drives it (see `harness_assembly`).+/// `ApprovalGateMiddleware` drives it (see `turn_middleware`).#[async_trait]impl ApprovalResolver<crate::agent::tinyagents::host::OpenHumanRunContext>for ApprovalSecurityMiddlewarediff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rsindex 89b43638f9..09fdba2c4b 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs@@ -413,7 +413,7 @@ impl TurnContextMiddleware {// `CLEARED_PLACEHOLDER` and it was summarizing placeholders. The one// component able to preserve those results in condensed form never saw// them. The caller now sites it AFTER compression, so the ladder reads- // summarize → blank → evict. See `assemble_turn_harness`.+ // summarize → blank → evict. See `install_turn_middleware`.if self.tool_result_budget_bytes > 0|| self.payload_summarizer.is_some()|| self.tokenjuice_compaction_enableddiff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_memory_budget_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_memory_budget_tests.rsindex 70bdfb7e3d..7fa2d17fbe 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_memory_budget_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_memory_budget_tests.rs@@ -90,7 +90,7 @@ fn response_with(calls: &[TaToolCall]) -> tinyinference_llm::model::ModelRespons/// The write churn #7293 capped (one save re-issued round after round) no/// longer spends the memory budget, so the repeat guard installed by-/// `harness_assembly` is what stops it: identical learns acknowledge+/// `turn_middleware` is what stops it: identical learns acknowledge/// identically, and the guard halts the run.#[tokio::test]async fn an_identical_learn_loop_is_halted_by_the_repeat_guard() {diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_stop_cause_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_stop_cause_tests.rsindex cb6cea71ca..7abbaf944e 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_stop_cause_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_stop_cause_tests.rs@@ -113,7 +113,7 @@ fn response_with(calls: &[TaToolCall]) -> ModelResponse {/// Drive `rounds` model responses that each re-issue one call per/// `(tool, path)` in `batch`, through the repeat guard and the failure breaker assembled as-/// `harness_assembly` does: the guard registered first (outermost), the+/// `turn_middleware` does: the guard registered first (outermost), the/// breaker after it, both on one stop-note slot. The read-only batch is/// admitted whole before any result folds back (concurrent execution); a/// call the guard refuses never runs and is answered with its refusal,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rsindex 4e6b81e178..4636a42375 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs@@ -1,6 +1,6 @@use crate::agent::tinyagents::middleware::tool_output::ToolOutputMiddleware;// Imported here rather than in the middleware module since #6014: the-// production install site moved to `assemble_turn_harness` (which names it+// production install site moved to `install_turn_middleware` (which names it// fully-qualified), so the module itself no longer references the type.use super::*;use tinyagents_harness::middleware::MicrocompactMiddleware;diff --git a/crates/openhuman-core/src/agent/tinyagents/run_mode.rs b/crates/openhuman-core/src/agent/tinyagents/run_mode.rsindex bb11a50a40..cf60f54cb8 100644--- a/crates/openhuman-core/src/agent/tinyagents/run_mode.rs+++ b/crates/openhuman-core/src/agent/tinyagents/run_mode.rs@@ -4,13 +4,13 @@//! (vendor tinyagents#211) gate side-effecting tools per-run via a live//! [`RunModeHandle`] the host can flip without restarting the run. OpenHuman's//! unit of "a run" for this purpose is a chat *thread*: the same thread is-//! driven through many independent turns (one `assemble_turn_harness` call+//! driven through many independent turns (one `install_turn_middleware` call//! each), so the mode has to live somewhere that outlives any one turn's//! [`crate::agent::tinyagents::host::OpenHumanRunContext`] — this process-wide,//! thread_id-keyed registry is that home.//!//! `plan_exit` (the tool) and the `agent.set_run_mode` / `agent.get_run_mode`-//! RPCs both read/write through here; `turn_runner` looks the handle up by+//! RPCs both read/write through here; `turn_exec` looks the handle up by//! `OpenHumanRunContext::thread_id` right before assembling each turn's//! harness and pushes `plan_mode_middleware(handle, ..)` when a handle exists//! for the thread.diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs b/crates/openhuman-core/src/agent/tinyagents/turn_models.rsindex 753caf416d..389e0f6443 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_models.rs@@ -14,7 +14,7 @@ use tinyinference_llm::model::{ResolvedModelRoute, RouteRecordingModel};/// built once from an openhuman [`Provider`] by [`build_turn_models`] — the/// single place a turn's `native model adapters are constructed (issue #4249, Phase 5).///-/// [`assemble_turn_harness`](super::harness_assembly::assemble_turn_harness) takes this bundle instead of the raw provider, so+/// [`OpenHumanTurnPlanner`](super::turn_plan::OpenHumanTurnPlanner) takes this bundle instead of the raw provider, so/// the harness assembly is expressed purely in crate model types; the/// `Provider` → `ChatModel` adaptation is confined to `build_turn_models`.pub(crate) struct TurnModels {@@ -170,7 +170,7 @@ impl ModelResolver<()> for TurnModelResolver {/// `OpenHumanBackendModel`, local/cloud → crate `OpenAiModel`).////// The `TurnModels` shape is identical to [`build_turn_models`] so-/// [`assemble_turn_harness`](super::harness_assembly::assemble_turn_harness) is unchanged. The provider metadata+/// [`OpenHumanTurnPlanner`](super::turn_plan::OpenHumanTurnPlanner) is unchanged. The provider metadata/// (`provider_id` / `native_tools` / `supports_vision`) is derived by the caller/// ([`TurnModelSource::build`]) from the resolved provider string and config./// `error_slot` is a freshdiff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rsindex 6e9088cf07..7e74c495e1 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs@@ -124,7 +124,7 @@ pub(crate) fn run_policy_for(max_iterations: usize, response_cache_enabled: bool/// providers keep the tight defaults so a wedged call is still caught fast.////// Cross-route fallback (`RunPolicy.fallback`) is orthogonal and populated-/// per-turn by [`assemble_turn_harness`](super::harness_assembly::assemble_turn_harness).+/// per-turn by [`turn_run_policy`](super::turn_plan::turn_run_policy).pub(crate) fn run_policy_for_provider(max_iterations: usize,response_cache_enabled: bool,diff --git a/crates/openhuman-core/src/agent/tools/plan_exit.rs b/crates/openhuman-core/src/agent/tools/plan_exit.rsindex db966f3605..6daaefb3b0 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit.rs@@ -6,7 +6,7 @@//! calling thread's `RunMode` (`agent::tinyagents::run_mode::set_mode`) back//! to `Build`, so the very next tool exposure/execution check on that thread//! sees every tool again — the actual gating lives in-//! `PlanModeMiddleware` (wired per-turn in `harness_assembly.rs`), not here;+//! `PlanModeMiddleware` (wired per-turn in `turn_middleware.rs`), not here;//! this tool only flips the live handle the middleware reads.//!//! Threadless callers (no `ToolRunContext::thread_id`, e.g. a test double ordiff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex eee9ecb8ff..c17ad89b8e 100644--- a/docs/TEST-COVERAGE-MATRIX.md+++ b/docs/TEST-COVERAGE-MATRIX.md@@ -209,7 +209,7 @@ Local inference runs against a runtime the user installs, starts, and pulls mode| 4.3.5 | Image Tool Contracts | RU | `crates/openhuman-core/src/media/image/` | ✅ | High-level `image_generation` / `view_image` schema, gating, serialization, prompt guidance, and contract e2e coverage for #2984 || 4.3.6 | Media generation (OpenRouter via backend proxy) | RU+E2E | `crates/openhuman-core/src/media/generation/tools_tests.rs`, `tests/media_generation_e2e.rs::media_tools_deliver_images_and_videos_through_the_backend_proxy`, `scripts/mock-api/routes/__tests__/media.test.mjs` | ✅ | `media_generate_image` / `media_generate_video` run TinyInference generators through `/agent-integrations/openrouter` (envelope, credential, `x-sdk-name`); a video job reporting `completed` with no outputs is polled through, not failed; one billed submit per call; local references confined to action/workspace dirs. || 4.3.7 | Mascot Avatar Animation | VU | `app/src/features/human/Mascot/RiveMascot.test.tsx`, `app/src/features/human/Mascot/riveMaps.test.ts` | ✅ | Rive `MascotSM` state machine: face→pose mapping, Oculus→`visme_codes` viseme normalization, and idle random pose rotation for the `tiny_mascot.riv` upgrade |-| 4.3.8 | Tool rules (allow / deny / hide / approval patterns) | RU | `crates/openhuman-core/src/tools/rules/ops_tests.rs`, `crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs`, `crates/openhuman-core/src/agent/tinyagents/harness_assembly_tests.rs`, `crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs`, `crates/openhuman-embed/src/agent/definition_tests.rs`, `vendor/tinyagents/crates/tinyagents-harness/src/agent_loop/tool_rules_tests.rs` | ✅ | `[tool_rules]` config, definition `disallowed_tools`/`tool_rules`, registry entries and `AgentDefinitionSpec::tool_rules` compose into rule layers; sub-agents inherit operator layers only; the turn harness carries them as `RunPolicy::tool_rules`, which the TinyAgents loop applies to the catalogue, `tool_search` and every call (loop behaviour covered upstream) |+| 4.3.8 | Tool rules (allow / deny / hide / approval patterns) | RU | `crates/openhuman-core/src/tools/rules/ops_tests.rs`, `crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs`, `crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs`, `crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs`, `crates/openhuman-embed/src/agent/definition_tests.rs`, `vendor/tinyagents/crates/tinyagents-harness/src/agent_loop/tool_rules_tests.rs` | ✅ | `[tool_rules]` config, definition `disallowed_tools`/`tool_rules`, registry entries and `AgentDefinitionSpec::tool_rules` compose into rule layers; sub-agents inherit operator layers only; the turn harness carries them as `RunPolicy::tool_rules`, which the TinyAgents loop applies to the catalogue, `tool_search` and every call (loop behaviour covered upstream) |### 4.4 Agent Harness Behaviorsdiff --git a/docs/gitbooks/en/developing/architecture/agent-harness.md b/docs/gitbooks/en/developing/architecture/agent-harness.mdindex 78ad4d8b67..cc5df41ce5 100644--- a/docs/gitbooks/en/developing/architecture/agent-harness.md+++ b/docs/gitbooks/en/developing/architecture/agent-harness.md@@ -619,7 +619,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_runner.rs`. |+| `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/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. |