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
feat(agent): host root session turns
Steven Enamakel7cfcfa8cf676
diff --git a/.sdd-progress.md b/.sdd-progress.mdindex 21b1929a7a..542380efa5 100644--- a/.sdd-progress.md+++ b/.sdd-progress.md@@ -10,6 +10,7 @@ Wave 3: complete in TinyAgents (all ten host capabilities, truthful unary/streamWave 4 Phase A: complete at OpenHuman commit 9baad52086 (canonical direct imports, behavior-free facade deletion, host-only conversion/tracing seams retained; independent Terra review PASS).Wave 4 Phase B1: complete through OpenHuman commit a3dcf3f897 (explicit OpenHumanRunContext foundation, ten-capability host bundle, canonical shared-tool adapter, call-identity-safe middleware migration, truthful routing-role projection, and boundary baseline reduced from 377 to 358; independent Terra re-review PASS). The context is intentionally not live yet; Phase B2 owns task-local and route cutover.Wave 4 Phase B2g: complete (root `RunContext<OpenHumanRunContext>` now carries the shared dispatch guard, attachment placeholders, and explicit child-usage ledger; synchronous descendants read and write those handles directly, `LastTurnUsage` is populated from the root ledger, and the three ambient turn-local modules are deleted). The guard keeps its host-owned pause and wall-clock policy, while deterministic tests cover pause/budget refusal and sibling-ledger isolation.+Wave 4 Phase C1: complete (the production root `ChatTurnGraph` now fails closed without retained hosted authority and otherwise enters the one process-shared `AgentHarness` through an invocation-local `AgentInvocation`/`InvocationRuntime`. The session's frozen prompt/context ladder remains the request, while the per-turn model route set, tools, policy session, progress, workspace, cancellation, steering, journal, artifacts, budgets, and terminal mapping stay invocation-local. Channel and sub-agent routes remain on the explicitly separate legacy runner. The exact boundary baseline is now 210, down by two root-route bridge entries.)Task -1: complete (git_attribution removed; focused behavioral Git-hardening test passed; re-review spec PASS and quality PASS with no findings).Task 0: complete (temporary exact baseline reduced from 455 to 377 after Phase A; checker scans all OpenHuman crates and TinyAgents facades; vendored dependency boundary 6/6; Terra re-review PASS).Task 1: in progress (TinyTools final is merged `7a40010` in PR #6; the source-breaking/tool-controlled trust experiment was removed and empty PR #7 closed; TinyAgents and OpenHuman direct-import consumers complete; final runtime deletion remains).diff --git a/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rs b/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rsindex 1234e72602..78a72ab6f8 100644--- a/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rs+++ b/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rs@@ -196,6 +196,7 @@ impl Agent {thread_id: self.thread_id.clone(),run_context: run_context.clone(),hosted_base: self.hosted_base.clone(),+ agent_id: self.agent_definition_id.clone(),}).await?;let subagent_usage_entries = run_context.subagent_usage_entries();diff --git a/crates/openhuman-core/src/agent/harness/session/turn/graph.rs b/crates/openhuman-core/src/agent/harness/session/turn/graph.rsindex f8f189b429..e70854d62a 100644--- a/crates/openhuman-core/src/agent/harness/session/turn/graph.rs+++ b/crates/openhuman-core/src/agent/harness/session/turn/graph.rs@@ -2,8 +2,7 @@//!//! Per the per-folder `graph.rs` convention, this module owns the chat folder's//! graph definition, its available tools, and its summarization step — all thin-//! over the shared tinyagents seam-//! ([`run_turn_via_tinyagents_shared`](crate::agent::tinyagents::run_turn_via_tinyagents_shared)).+//! over the hosted TinyAgents invocation seam.//!//! **Graph.** The top-level interactive chat turn: a single agent-loop turn//! driven by the tinyagents harness, observed via the session's `on_progress`@@ -34,7 +33,7 @@ use crate::agent::harness::{with_current_sandbox_mode, SandboxMode};use crate::agent::messages::ChatMessage;use crate::agent::progress::AgentProgress;use crate::agent::tinyagents::{- run_turn_via_tinyagents_shared, TinyagentsTurnOutcome, TurnContextMiddleware,+ run_root_turn_via_hosted_agent, TinyagentsTurnOutcome, TurnContextMiddleware,};use crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS;use tinytools::Tool;@@ -97,6 +96,9 @@ pub(crate) struct ChatTurnGraph {pub run_context: crate::agent::tinyagents::host::OpenHumanRunContext,/// Durable host authority captured at session construction.pub hosted_base: Option<std::sync::Arc<crate::agent::tinyagents::host::OpenHumanHostBase>>,+ /// Stable definition id for hosted resolution. The transcript-facing name+ /// may contain a thread suffix and is never an authority lookup key.+ pub agent_id: String,}/// Drive the chat turn graph: a thin wrapper over the shared tinyagents seam@@ -104,6 +106,11 @@ pub(crate) struct ChatTurnGraph {/// ([`core`](super::core) folds usage, persists the conversation, and handles a/// cap-hit checkpoint).pub(crate) async fn run_chat_turn_graph(graph: ChatTurnGraph) -> Result<TinyagentsTurnOutcome> {+ let hosted_base = graph.hosted_base.clone().ok_or_else(|| {+ anyhow::anyhow!(+ "hosted root invocation is unavailable because the session has no hosted authority"+ )+ })?;// Fail-closed allowlist plumbing (issue #4452): the shared seam now takes an// `Option<HashSet<String>>` where `None` = no filter (all visible tools) and// `Some(set)` = exactly those tools. The chat path's historical convention is@@ -124,8 +131,10 @@ pub(crate) async fn run_chat_turn_graph(graph: ChatTurnGraph) -> Result<Tinyagenrun_context.workspace = graph.workspace_descriptor.clone().or(run_context.workspace);run_context.sandbox_mode = Some(graph.sandbox_mode);run_context.thread_id = graph.thread_id;- run_turn_via_tinyagents_shared(+ run_root_turn_via_hosted_agent(run_context,+ hosted_base,+ graph.agent_id,graph.turn_models,provider_id,&graph.model,@@ -139,8 +148,6 @@ pub(crate) async fn run_chat_turn_graph(graph: ChatTurnGraph) -> Result<Tinyagenvec![graph.tools, graph.synthesized_tools],visible_tool_names,graph.max_iterations,- // Top-level chat turn — no child-progress attribution.- None,graph.context_window,// Mid-flight steering from the session's run queue.graph.run_queue,@@ -167,9 +174,6 @@ pub(crate) async fn run_chat_turn_graph(graph: ChatTurnGraph) -> Result<Tinyagengraph.context_mw,// Builder-configured tool policy enforcement (session chat path).graph.tool_policy,- // Interactive chat turn — response caching MUST stay off so a live user- // turn is never served a cached model response (correctness/safety).- false,// #4457 (defect C): defer the terminal `TurnCompleted` to the caller.// The session path (`run_turn_impl` in `turn/core.rs`) runs its cap/#4093// wrap-up (`summarize_turn_wrapup`) *after* this seam returns and thendiff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rsindex 0dcf128472..c5c3c61501 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs@@ -123,6 +123,9 @@ pub(super) fn assemble_turn_harness(tool_policy: Option<ToolPolicyEnforcement>,required_capabilities: Option<CapabilitySet>,deterministic_cacheable: bool,+ // Hosted roots authorize tools through `OpenHumanSecurityGate`; installing+ // the legacy approval middleware as well would issue a second approval.+ hosted_security_gate: bool,// Whether this run pauses gracefully at its model-call cap (issue #6014).// Only such a run gets the in-loop conclusion: a run that errors at its cap// instead (the channel/CLI path, which maps the stop to@@ -505,9 +508,11 @@ pub(super) fn assemble_turn_harness(// `ApprovalGate`, a denial short-circuits with a model-consumable result, and// an approved call records a terminal audit row. Replaces the inline approval// block that used to live in the legacy tool adapter.- harness.push_tool_middleware(Arc::new(middleware::ApprovalSecurityMiddleware::new(- tool_sets.clone(),- )));+ if !hosted_security_gate {+ harness.push_tool_middleware(Arc::new(middleware::ApprovalSecurityMiddleware::new(+ tool_sets.clone(),+ )));+ }// CLI/RPC-only scope gate — a tool restricted to explicit CLI/RPC invocation// must not run from the model loop. Intrinsic to the tool, so installed ondiff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rsindex a37a504848..5a174755bd 100644--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs@@ -78,7 +78,7 @@ pub(crate) use turn_outcome::{HaltSummarySlot, TinyagentsTurnOutcome, ToolCallOutcome, ToolOutcomeSink,};pub(crate) use turn_policy::{agent_turn_wall_clock_ms, ToolPolicyEnforcement};-pub(crate) use turn_runner::run_turn_via_tinyagents_shared;+pub(crate) use turn_runner::{run_root_turn_via_hosted_agent, run_turn_via_tinyagents_shared};// Test-only glue so `tinyagents_tests.rs`'s `use super::*;` sees the// lower-level policy helpers it exercises directly (they otherwise staydiff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rsindex d9c5743140..8306275de2 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs@@ -12,6 +12,7 @@ use crate::agent::harness::MAX_SPAWN_DEPTH;/// so it can install the [`ToolPolicyMiddleware`](super::middleware::ToolPolicyMiddleware)./// `None` means "no policy enforcement on this turn" (the channel/CLI + sub-agent/// paths, which carry their own gating).+#[derive(Clone)]pub(crate) struct ToolPolicyEnforcement {pub policy: std::sync::Arc<dyn crate::agent::tool_policy::ToolPolicy>,/// The session's channel-permission snapshot — enforces the per-channeldiff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rsindex f4fbfd1fc0..cc16309ff1 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs@@ -11,13 +11,18 @@ use crate::agent::tinyagents::model::TurnChatModel;#[cfg(test)]use crate::agent::tinyagents::turn_policy::run_policy_for;use std::collections::HashSet;-use std::sync::Arc;+use std::sync::{Arc, LazyLock};use anyhow::Result;+use async_trait::async_trait;use futures::StreamExt;use tinyagents_harness::agent_loop::AgentStreamItem;use tinyagents_harness::context::RunConfig;use tinyagents_harness::events::EventSink;+use tinyagents_harness::host::{ContextComposer, TurnContextRequest};+use tinyagents_harness::runtime::{+ AgentHarness, AgentInvocation, AgentTurnRequest, InvocationRuntime,+};use tinyagents_harness::store::StoreRegistry;use tinyagents_registry::DiagnosticSeverity;@@ -39,6 +44,46 @@ use tinyagents_harness::ids::TaskId;use super::ToolPolicyEnforcement;+/// The durable root entry point for hosted turns. It intentionally carries no+/// product authority: models, tools, middleware, progress and host capabilities+/// are attached through an [`InvocationRuntime`] and [`AgentInvocation`] for+/// each root. That prevents concurrent sessions from replacing one another's+/// security or workspace state on a shared harness.+static ROOT_HOSTED_HARNESS: LazyLock<AgentHarness<(), OpenHumanRunContext>> =+ LazyLock::new(AgentHarness::new);++fn root_hosted_harness() -> &'static AgentHarness<(), OpenHumanRunContext> {+ &ROOT_HOSTED_HARNESS+}++#[cfg(test)]+#[path = "turn_runner_tests.rs"]+mod tests;++/// Keeps the session's already-built system/context ladder authoritative while+/// still entering TinyAgents through its hosted invocation boundary. The+/// session request contains the frozen system prompt, prompt policy boundary,+/// context additions and provider-ready history; composing another prompt here+/// would duplicate it and move the cache prefix.+struct PrecomposedRootContext;++#[async_trait]+impl ContextComposer for PrecomposedRootContext {+ async fn compose_system_prompt(+ &self,+ _request: &TurnContextRequest,+ ) -> tinyagents_harness::Result<String> {+ Ok(String::new())+ }++ async fn preamble(+ &self,+ _request: &TurnContextRequest,+ ) -> tinyagents_harness::Result<Vec<tinyinference_llm::message::Message>> {+ Ok(Vec::new())+ }+}+/// Drive an agent turn through the `tinyagents` agent-loop harness.////// Registers `provider` as the default model and every entry in `resolved_tools`@@ -223,6 +268,106 @@ pub(crate) async fn run_turn_via_tinyagents_shared(// Completed upserts). Callers with no post-run streaming (channel/CLI) pass// `false` and rely on this seam's emit for parity with the legacy engine.defer_turn_completed_to_caller: bool,+) -> Result<TinyagentsTurnOutcome> {+ run_turn_via_tinyagents_inner(+ run_context,+ turn_models,+ provider_id,+ model,+ history,+ tool_sets,+ allowed,+ max_iterations,+ subagent_scope,+ context_window,+ run_queue,+ early_exit_tools,+ pause_at_cap,+ max_output_tokens,+ context_mw,+ tool_policy,+ deterministic_cacheable,+ defer_turn_completed_to_caller,+ None,+ )+ .await+}++/// Hosted root-turn entry point.+///+/// Channel and sub-agent callers deliberately remain on+/// [`run_turn_via_tinyagents_shared`] until their own cutovers. A root cannot+/// reach that legacy entry: it supplies durable host authority here and this+/// function drives the process-shared harness through `AgentInvocation`.+#[allow(clippy::too_many_arguments)]+pub(crate) async fn run_root_turn_via_hosted_agent(+ run_context: OpenHumanRunContext,+ hosted_base: Arc<crate::agent::tinyagents::host::OpenHumanHostBase>,+ agent_id: String,+ turn_models: TurnModels,+ provider_id: String,+ model: &str,+ history: Vec<ChatMessage>,+ tool_sets: Vec<Arc<Vec<Box<dyn tinytools::Tool>>>>,+ allowed: Option<HashSet<String>>,+ max_iterations: usize,+ context_window: Option<u64>,+ run_queue: Option<Arc<RunQueue>>,+ early_exit_tools: &[&str],+ pause_at_cap: bool,+ max_output_tokens: Option<u32>,+ context_mw: TurnContextMiddleware,+ tool_policy: Option<ToolPolicyEnforcement>,+ defer_turn_completed_to_caller: bool,+) -> Result<TinyagentsTurnOutcome> {+ run_turn_via_tinyagents_inner(+ run_context,+ turn_models,+ provider_id,+ model,+ history,+ tool_sets,+ allowed,+ max_iterations,+ None,+ context_window,+ run_queue,+ early_exit_tools,+ pause_at_cap,+ max_output_tokens,+ context_mw,+ tool_policy,+ false,+ defer_turn_completed_to_caller,+ Some((hosted_base, agent_id)),+ )+ .await+}++#[allow(clippy::too_many_arguments)]+async fn run_turn_via_tinyagents_inner(+ run_context: OpenHumanRunContext,+ turn_models: TurnModels,+ provider_id: String,+ model: &str,+ history: Vec<ChatMessage>,+ tool_sets: Vec<Arc<Vec<Box<dyn tinytools::Tool>>>>,+ allowed: Option<HashSet<String>>,+ max_iterations: usize,+ subagent_scope: Option<SubagentScope>,+ context_window: Option<u64>,+ run_queue: Option<Arc<RunQueue>>,+ early_exit_tools: &[&str],+ pause_at_cap: bool,+ max_output_tokens: Option<u32>,+ context_mw: TurnContextMiddleware,+ tool_policy: Option<ToolPolicyEnforcement>,+ deterministic_cacheable: bool,+ defer_turn_completed_to_caller: bool,+ hosted_root: Option<(+ Arc<crate::agent::tinyagents::host::OpenHumanHostBase>,+ String,+ )>,) -> Result<TinyagentsTurnOutcome> {// The host context is the sole turn carrier. Pulling the sender into this// local keeps the event bridge API compact without creating a second@@ -232,6 +377,20 @@ pub(crate) async fn run_turn_via_tinyagents_shared(// otherwise the harness model-call cap would be zero and abort the run before// the first provider call.let max_iterations = effective_max_iterations(max_iterations);+ // Hosted resolution must expose this turn's already-selected primary and+ // fallback models. Build the resolver before assembly consumes the model+ // bundle; it is installed only on the invocation-local host bundle.+ let hosted_model_resolver = hosted_root.as_ref().map(|_| {+ Arc::new(+ crate::agent::tinyagents::turn_models::TurnModelResolver::from_turn_models(+ &turn_models,+ ),+ ) as Arc<dyn tinyagents_harness::host::ModelResolver<()>>+ });+ // Assembly consumes the registry sets. The host security adapter must see+ // the exact same `Arc`-shared instances, so retain only the cheap Arc clone+ // for a hosted invocation (never clone the tools themselves).+ let hosted_tool_sets = hosted_root.as_ref().map(|_| tool_sets.clone());// The turn's crate `ChatModel` set (`turn_models`) and the provider telemetry// id are built by the caller via `build_turn_models` — the seam entry is// crate-native and no longer names `Provider` (issue #4249, Phase 5). The@@ -266,9 +425,10 @@ pub(crate) async fn run_turn_via_tinyagents_shared(early_exit_tools,context_mw,run_context.stop_hooks.clone(),- tool_policy,+ tool_policy.clone(),routes::turn_required_capabilities(model),deterministic_cacheable,+ hosted_root.is_some(),pause_at_cap,);@@ -579,7 +739,73 @@ pub(crate) async fn run_turn_via_tinyagents_shared(// overflows when the parent + child drives compose. Boxing keeps only a// pointer on the stack at each level.let resolved_route_slot = run_context.resolved_route.clone();- let run_result = if streaming {+ let run_result = if let Some((base, agent_id)) = hosted_root {+ let tool_sets = hosted_tool_sets.expect("hosted root retained its tool sets");+ let mut host_bundle =+ crate::agent::tinyagents::host::OpenHumanHostBundleFactory::build_for_invocation(+ crate::agent::tinyagents::host::OpenHumanHostInvocationInputs {+ base,+ tool_sets,+ tool_policy: tool_policy+ .as_ref()+ .map(|policy| Arc::new(policy.session.clone())),+ model_resolver: hosted_model_resolver,+ },+ &run_context,+ );+ // The root session has already assembled its exact system prompt,+ // learned context and history before this graph runs. Keep those bytes+ // as the hosted request rather than composing/recalling a second copy;+ // the host still owns definition resolution, security, model routing,+ // budgets, progress and outcome classification for this invocation.+ host_bundle.capabilities.context = Arc::new(PrecomposedRootContext);+ host_bundle.capabilities.memory = None;+ host_bundle.capabilities.experience = None;+ // Session finalization owns the full-fidelity hook payload (including+ // sanitized per-tool outcomes). The generic names-only summary would+ // otherwise fire the same hooks a second time.+ host_bundle.capabilities.learning = None;++ let invocation = AgentInvocation::new(+ host_bundle.capabilities,+ AgentTurnRequest::new(agent_id, input),+ ctx,+ )+ .with_runtime(InvocationRuntime::new(harness));+ let state = ();+ if streaming {+ let stream = root_hosted_harness()+ .invoke_agent_stream(invocation, &state)+ .await;+ match stream {+ Ok(mut stream) => {+ let mut terminal = None;+ while let Some(item) = stream.next().await {+ match item {+ AgentStreamItem::Event(_) => {}+ AgentStreamItem::Completed(run) => {+ terminal = Some(Ok(*run));+ break;+ }+ AgentStreamItem::Failed { error, .. } => {+ terminal =+ Some(Err(tinyagents_harness::TinyAgentsError::Model(error)));+ break;+ }+ }+ }+ terminal.unwrap_or_else(|| {+ Err(tinyagents_harness::TinyAgentsError::Model(+ "hosted agent stream ended without terminal run".to_string(),+ ))+ })+ }+ Err(error) => Err(error),+ }+ } else {+ root_hosted_harness().invoke_agent(invocation, &state).await+ }+ } else if streaming {let mut stream = Box::pin(harness.invoke_stream_in_context(&(), ctx, input));let mut terminal = None;while let Some(item) = stream.next().await {diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rsnew file mode 100644index 0000000000..743ff40328--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs@@ -0,0 +1,154 @@+use super::*;+use crate::agent::tinyagents::TurnModelSource;+use std::sync::Arc;++fn hosted_base() -> Arc<crate::agent::tinyagents::host::OpenHumanHostBase> {+ Arc::new(crate::agent::tinyagents::host::OpenHumanHostBase {+ config: Arc::new(crate::config::Config::default()),+ definitions: Arc::new(+ crate::agent::harness::definition::AgentDefinitionRegistry::builtins_only(),+ ),+ security_policy: Arc::new(crate::security::policy::SecurityPolicy::default()),+ memory: crate::memory::test_support::noop_memory(),+ shared_experience_memory: None,+ profile_id: None,+ post_turn_hooks: Vec::new(),+ })+}++fn root_models(reply: &str) -> TurnModels {+ let model: Arc<dyn tinyinference_llm::model::ChatModel<()>> =+ Arc::new(tinyagents_harness::testkit::ScriptedModel::replies(vec![+ reply,+ ]));+ TurnModelSource::from_model(model)+ .build("root-test-model", 0.0, None, None)+ .expect("scripted turn models build")+}++fn root_messages(label: &str) -> Vec<ChatMessage> {+ vec![+ ChatMessage::system(format!("system-{label}")),+ ChatMessage::user(format!("user-{label}")),+ ]+}++fn root_context(+ thread_id: &str,+ workspace: &str,+ progress: tokio::sync::mpsc::Sender<crate::agent::progress::AgentProgress>,+) -> OpenHumanRunContext {+ let mut context = OpenHumanRunContext::new();+ context.origin = Some(crate::agent::turn_origin::AgentTurnOrigin::WebChat {+ thread_id: thread_id.to_string(),+ client_id: format!("client-{thread_id}"),+ request_id: Some(format!("request-{thread_id}")),+ });+ context.thread_id = Some(thread_id.to_string());+ context.workspace = Some(tinytools::WorkspaceDescriptor::new(workspace));+ context.progress = Some(progress);+ context+}++async fn run_root(+ base: Arc<crate::agent::tinyagents::host::OpenHumanHostBase>,+ context: OpenHumanRunContext,+ reply: &str,+) -> TinyagentsTurnOutcome {+ run_root_turn_via_hosted_agent(+ context,+ base,+ "main".to_string(),+ root_models(reply),+ "test".to_string(),+ "root-test-model",+ root_messages(reply),+ vec![Arc::new(Vec::new())],+ Some(Default::default()),+ 2,+ None,+ None,+ &[],+ false,+ None,+ TurnContextMiddleware::default(),+ None,+ true,+ )+ .await+ .expect("hosted root succeeds")+}++#[tokio::test]+async fn precomposed_root_context_does_not_duplicate_the_session_prompt_or_preamble() {+ let request =+ TurnContextRequest::new("main", tinyagents_harness::ids::ThreadId::new("t"), "hi");++ assert_eq!(+ PrecomposedRootContext+ .compose_system_prompt(&request)+ .await+ .expect("precomposed root context composes"),+ "",+ "the frozen session system/context ladder stays in the invocation request"+ );+ assert!(+ PrecomposedRootContext+ .preamble(&request)+ .await+ .expect("precomposed root context builds preamble")+ .is_empty(),+ "host preparation must not insert a second root preamble"+ );+}++#[test]+fn hosted_roots_share_only_an_unconfigured_process_harness() {+ let first = root_hosted_harness() as *const _;+ let second = root_hosted_harness() as *const _;++ assert_eq!(first, second, "all roots enter the same durable harness");+ assert!(+ root_hosted_harness().models().default_name().is_none(),+ "models are invocation-local overlays, never mutable shared root state"+ );+ assert!(+ root_hosted_harness().tools().names().is_empty(),+ "tools are invocation-local overlays, never mutable shared root state"+ );+}++#[tokio::test]+async fn concurrent_hosted_roots_keep_models_progress_workspace_and_origin_isolated() {+ let base = hosted_base();+ let (left_progress, mut left_events) = tokio::sync::mpsc::channel(32);+ let (right_progress, mut right_events) = tokio::sync::mpsc::channel(32);++ let (left, right) = tokio::join!(+ run_root(+ base.clone(),+ root_context("left", "/tmp/left", left_progress),+ "left"+ ),+ run_root(+ base,+ root_context("right", "/tmp/right", right_progress),+ "right"+ ),+ );++ assert_eq!(left.text, "left");+ assert_eq!(right.text, "right");+ assert_ne!(+ left.history, right.history,+ "each overlay kept its transcript"+ );+ assert!(+ left_events.try_recv().is_ok(),+ "the left invocation retained its own progress sink"+ );+ assert!(+ right_events.try_recv().is_ok(),+ "the right invocation retained its own progress sink"+ );+}diff --git a/scripts/ci/agent-runtime-boundary-baseline.json b/scripts/ci/agent-runtime-boundary-baseline.jsonindex 6255dda441..22ebfa1778 100644--- a/scripts/ci/agent-runtime-boundary-baseline.json+++ b/scripts/ci/agent-runtime-boundary-baseline.json@@ -13,20 +13,6 @@"text": "let outcome = run_turn_via_tinyagents_shared(","occurrence": 1},- {- "rule": "openhuman-runtime-bridge",- "path": "crates/openhuman-core/src/agent/harness/session/turn/graph.rs",- "line": 37,- "text": "run_turn_via_tinyagents_shared, TinyagentsTurnOutcome, TurnContextMiddleware,",- "occurrence": 1- },- {- "rule": "openhuman-runtime-bridge",- "path": "crates/openhuman-core/src/agent/harness/session/turn/graph.rs",- "line": 125,- "text": "run_turn_via_tinyagents_shared(",- "occurrence": 1- },{"rule": "openhuman-runtime-bridge","path": "crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/dispatch.rs",@@ -52,27 +38,27 @@"rule": "openhuman-runtime-bridge","path": "crates/openhuman-core/src/agent/tinyagents/mod.rs","line": 81,- "text": "pub(crate) use turn_runner::run_turn_via_tinyagents_shared;",+ "text": "pub(crate) use turn_runner::{run_root_turn_via_hosted_agent, run_turn_via_tinyagents_shared};","occurrence": 1},{"rule": "openhuman-runtime-bridge","path": "crates/openhuman-core/src/agent/tinyagents/turn_runner.rs",- "line": 27,+ "line": 32,"text": "use crate::agent::tinyagents::harness_assembly::{assemble_turn_harness, AssembledTurnHarness};","occurrence": 1},{"rule": "openhuman-runtime-bridge","path": "crates/openhuman-core/src/agent/tinyagents/turn_runner.rs",- "line": 199,+ "line": 244,"text": "pub(crate) async fn run_turn_via_tinyagents_shared(","occurrence": 1},{"rule": "openhuman-runtime-bridge","path": "crates/openhuman-core/src/agent/tinyagents/turn_runner.rs",- "line": 257,+ "line": 416,"text": "} = assemble_turn_harness(","occurrence": 1},@@ -268,7 +254,7 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/harness/session/builder/factory.rs",- "line": 1513,+ "line": 1529,"text": "let root = crate::agent::turn_workspace::current()?;","occurrence": 1},@@ -289,14 +275,14 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/harness/session/turn/graph.rs",- "line": 33,+ "line": 32,"text": "use crate::agent::harness::{with_current_sandbox_mode, SandboxMode};","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/harness/session/turn/graph.rs",- "line": 119,+ "line": 128,"text": "with_current_sandbox_mode(graph.sandbox_mode, async {","occurrence": 1},