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
fix(agent): preserve delegation parent carrier
Steven Enamakele48470886532
diff --git a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph.rs b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph.rsindex 12472bd90e..7fe34dd1f5 100644--- a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph.rs+++ b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph.rs@@ -43,6 +43,8 @@ mod worker_mirror;// Re-exported under the original flat `graph::` path so external callers// (`ops/mod.rs`, `ops/runner.rs`, `graph_tests.rs`'s `use super::*`) are// unaffected by the responsibility split.+#[cfg(test)]+pub(super) use dispatch::inherited_thread_id;pub(crate) use dispatch::run_agent_turn_request_via_default_graph;pub(super) use dispatch::{run_subagent_via_graph, AggregatedUsage};diff --git a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/dispatch.rsindex 3d3c41cf1a..1c23801ef6 100644--- a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/dispatch.rs+++ b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/dispatch.rs@@ -270,7 +270,10 @@ pub(in super::super) async fn run_subagent_via_graph(// workspace grants, and dispatch state follow the child while its route and// subagent-usage slots remain isolated.let mut child_context = run_context.child();- child_context.thread_id = thread_id.clone();+ // A parallel task may omit `thread_id`; that means inherit the parent+ // conversation, not erase it. Only an explicit task thread may replace+ // the typed carrier's inherited affinity.+ child_context.thread_id = inherited_thread_id(child_context.thread_id, thread_id.clone());child_context.progress = on_progress.clone().or(child_context.progress);child_context.workspace = workspace_descriptor.clone().or(child_context.workspace);let run_result = Box::pin(run_turn_via_tinyagents_shared(@@ -574,6 +577,15 @@ pub(in super::super) async fn run_subagent_via_graph())}+/// A task-specific thread explicitly routes a worker; an absent task thread+/// leaves the parent run's transcript affinity intact.+pub(crate) fn inherited_thread_id(+ parent_thread_id: Option<String>,+ task_thread_id: Option<String>,+) -> Option<String> {+ task_thread_id.or(parent_thread_id)+}+/// Build the sub-agent turn's [`TurnContextMiddleware`] from the live/// `[context]` config and the agent's TokenJuice profile (#4466), mirroring the/// chat path (`session/turn/core.rs`). Falls back todiff --git a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph_tests.rs b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph_tests.rsindex 3c9b569a64..986ef7fed6 100644--- a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph_tests.rs+++ b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph_tests.rs@@ -81,6 +81,21 @@ impl ChatModel<()> for TwoStepProvider {#[path = "graph_failed_run_tests.rs"]mod graph_failed_run_tests;+#[test]+fn parallel_worker_without_thread_keeps_parent_transcript_affinity() {+ assert_eq!(+ inherited_thread_id(Some("parent-thread".to_string()), None),+ Some("parent-thread".to_string())+ );+ assert_eq!(+ inherited_thread_id(+ Some("parent-thread".to_string()),+ Some("task-thread".to_string())+ ),+ Some("task-thread".to_string())+ );+}+#[tokio::test]async fn subagent_runs_through_the_graph_engine_with_real_tools() {let provider = Arc::new(TwoStepProvider {diff --git a/crates/openhuman-core/src/agent/orchestration/README.md b/crates/openhuman-core/src/agent/orchestration/README.mdindex 740068c1b6..98aa64de13 100644--- a/crates/openhuman-core/src/agent/orchestration/README.md+++ b/crates/openhuman-core/src/agent/orchestration/README.md@@ -126,7 +126,13 @@ name:`dispatch.rs` (`dispatch_subagent`, the shared spawn path every tool abovecalls), `awaiting_user.rs` (the awaiting-user envelope), and`worker_thread.rs` (worker thread creation) are `pub(crate)` helpers, not-tools. Execution itself routes through `agent::harness::run_subagent`.+tools. Live harness registrations use typed `ToolDispatch<(),+OpenHumanRunContext>` wrappers and fork the parent carrier for every child,+so cancellation, origin, progress, dispatch state, thread, and workspace stay+attached. `delegate_to` retains its concrete enum-to-agent routing table in+its schema metadata at registration; it never broadens a call by rebuilding+targets from the global agent registry. Execution itself routes through+`agent::harness::run_subagent`.## Persistencediff --git a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rsindex 42d311afec..491055d53c 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs@@ -71,7 +71,15 @@ use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolResult/// delegation section and the tests cannot disagree about it.pub const DELEGATE_TO_TOOL_NAME: &str = "delegate_to";+/// JSON-Schema extension that carries the exact selector-to-agent mapping the+/// collapsed tool was built with. The harness registers tools behind `dyn+/// Tool`, so this keeps the concrete tool's routing table alongside its+/// advertised enum without a downcast or a later lookup against every global+/// definition.+pub(crate) const DISPATCH_TARGETS_SCHEMA_KEY: &str = "x-openhuman-delegation-targets";+/// One routable sub-agent.+#[derive(Clone, Debug, PartialEq, Eq)]pub struct DelegateTarget {/// The name this target had when it was its own tool, and the value the/// `agent` enum takes. Keeping the old name as the enum value is what lets@@ -118,6 +126,20 @@ impl CollapsedDelegationTool {self.targets.iter().map(|t| t.tool_name.as_str()).collect()}+ fn dispatch_targets_schema(&self) -> Value {+ Value::Array(+ self.targets+ .iter()+ .map(|target| {+ json!({+ "tool_name": target.tool_name,+ "agent_id": target.agent_id,+ })+ })+ .collect(),+ )+ }+/// The routable names, for the prompt renderer and the tests.pub fn target_names(&self) -> Vec<&str> {self.agent_enum()@@ -183,6 +205,7 @@ impl Tool for CollapsedDelegationTool {}}});+ schema[DISPATCH_TARGETS_SCHEMA_KEY] = self.dispatch_targets_schema();let properties = schema["properties"].as_object_mut().expect("properties is an object literal above");@@ -239,6 +262,72 @@ impl Tool for CollapsedDelegationTool {}}+/// Recover the concrete collapsed target table retained in the advertised+/// schema for typed harness registration. Reject malformed metadata instead+/// of widening the route to every entry in the process-wide definition+/// registry.+pub(crate) fn dispatch_targets_from_schema(schema: &Value) -> Result<Vec<DelegateTarget>, String> {+ let enum_names = schema+ .pointer("/properties/agent/enum")+ .and_then(Value::as_array)+ .ok_or_else(|| "delegate_to schema is missing `properties.agent.enum`".to_string())?;+ let enum_names: Vec<&str> = enum_names+ .iter()+ .map(|value| {+ value+ .as_str()+ .filter(|name| !name.trim().is_empty())+ .ok_or_else(|| "delegate_to agent enum contains a non-string value".to_string())+ })+ .collect::<Result<_, _>>()?;+ let encoded_targets = schema+ .get(DISPATCH_TARGETS_SCHEMA_KEY)+ .and_then(Value::as_array)+ .ok_or_else(|| "delegate_to schema is missing its target mapping".to_string())?;+ let targets: Vec<DelegateTarget> = encoded_targets+ .iter()+ .map(|value| {+ let object = value+ .as_object()+ .ok_or_else(|| "delegate_to target mapping entry is not an object".to_string())?;+ let required = |key: &str| {+ object+ .get(key)+ .and_then(Value::as_str)+ .filter(|value| !value.trim().is_empty())+ .map(str::to_owned)+ .ok_or_else(|| format!("delegate_to target mapping is missing `{key}`"))+ };+ Ok(DelegateTarget {+ tool_name: required("tool_name")?,+ agent_id: required("agent_id")?,+ // Descriptions are prompt-only routing guidance. The typed+ // dispatch needs the exact selector-to-agent mapping, not a+ // second copy of model-visible prose.+ description: String::new(),+ })+ })+ .collect::<Result<_, String>>()?;+ if targets.len() != enum_names.len()+ || targets+ .iter()+ .map(|target| target.tool_name.as_str())+ .ne(enum_names.iter().copied())+ || targets.iter().any(|target| {+ targets+ .iter()+ .filter(|candidate| candidate.tool_name == target.tool_name)+ .count()+ != 1+ })+ {+ return Err(+ "delegate_to target mapping does not exactly match its advertised agent enum".into(),+ );+ }+ Ok(targets)+}+/// Execute a collapsed hand-off with an explicit child run carrier.pub(crate) async fn execute_collapsed_delegation(targets: &[DelegateTarget],diff --git a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation_tests.rsindex 76847746ab..0de914fdcb 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation_tests.rs@@ -47,6 +47,20 @@ fn the_schema_advertises_every_target() {assert_eq!(listed, vec!["research", "review_code"]);}+#[test]+fn dispatch_target_mapping_matches_the_advertised_enum_and_agent_ids() {+ let tool = tool();+ let targets = dispatch_targets_from_schema(&tool.parameters_schema())+ .expect("concrete collapsed tool publishes a dispatch map");+ assert_eq!(+ targets+ .iter()+ .map(|target| (target.tool_name.as_str(), target.agent_id.as_str()))+ .collect::<Vec<_>>(),+ vec![("research", "researcher"), ("review_code", "code_reviewer")]+ );+}+#[test]fn the_schema_carries_the_whole_delegation_envelope() {// The collapse must not quietly drop a field the members accepted:diff --git a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rsindex 37d224b8da..2e2d4bf8f1 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs@@ -85,6 +85,7 @@ impl ContinueSubagentTool {agent_id: &str,message: &str,tool_context: Option<&dyn ToolRunContext>,+ run_context: crate::agent::tinyagents::host::OpenHumanRunContext,) -> anyhow::Result<ToolResult> {use crate::agent::orchestration::subagent_sessions::{self, SubagentSessionStore};@@ -151,7 +152,7 @@ impl ContinueSubagentTool {);}super::spawn_async_subagent::SpawnAsyncSubagentTool::new()- .execute_with_context(async_args, ToolCallOptions::default(), tool_context)+ .execute_with_parent_context(async_args, tool_context, run_context).await}}@@ -313,7 +314,14 @@ impl ContinueSubagentTool {// workflow_builder ("looks good, save it") instead of// re-delegating a fresh, stateless one.return self- .resume_from_durable_store(&parent, &task_id, &agent_id, &message, tool_context)+ .resume_from_durable_store(+ &parent,+ &task_id,+ &agent_id,+ &message,+ tool_context,+ run_context,+ ).await;}};@@ -400,7 +408,9 @@ impl ContinueSubagentTool {}// Build options with initial_history for replay- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());+ let workspace_descriptor = tool_context+ .and_then(|ctx| ctx.workspace().cloned())+ .or_else(|| run_context.workspace.clone());let worktree_action_dir = workspace_descriptor.as_ref().map(|descriptor| descriptor.root.clone());@@ -421,6 +431,7 @@ impl ContinueSubagentTool {task_id: Some(task_id.clone()),thread_id: tool_context.and_then(ToolRunContext::thread_id)+ .or(run_context.thread_id.as_deref()).map(str::to_owned),run_context,worker_thread_id: checkpoint.worker_thread_id.clone(),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rsindex ef94b3bd93..6e6ff6ef3f 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs@@ -22,15 +22,25 @@ pub(crate) struct DelegationDispatch {}enum DelegationDispatchKind {- Collapsed,- Integrations { connected_toolkits: Vec<String> },+ Collapsed {+ targets: Result<Vec<super::collapsed_delegation::DelegateTarget>, String>,+ },+ Integrations {+ connected_toolkits: Vec<String>,+ },Archetype,}impl DelegationDispatch {pub(crate) fn for_tool(tool: Arc<dyn tinytools::Tool>) -> Option<Self> {let kind = match tool.name() {- super::collapsed_delegation::DELEGATE_TO_TOOL_NAME => DelegationDispatchKind::Collapsed,+ super::collapsed_delegation::DELEGATE_TO_TOOL_NAME => {+ DelegationDispatchKind::Collapsed {+ targets: super::collapsed_delegation::dispatch_targets_from_schema(+ &tool.parameters_schema(),+ ),+ }+ }super::skill_delegation::INTEGRATIONS_DELEGATE_TOOL_NAME => {let connected_toolkits = tool.parameters_schema()@@ -65,26 +75,17 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Dlet tool_context = ToolExecutionContext::from_run_context(parent);let child = parent.data.child();match &self.kind {- DelegationDispatchKind::Collapsed => {- let targets: Vec<super::collapsed_delegation::DelegateTarget> =- AgentDefinitionRegistry::global()- .map(|registry| {- registry- .list()- .into_iter()- .map(|definition| super::collapsed_delegation::DelegateTarget {- tool_name: definition- .delegate_name- .clone()- .unwrap_or_else(|| format!("delegate_{}", definition.id)),- agent_id: definition.id.clone(),- description: definition.when_to_use.clone(),- })- .collect::<Vec<_>>()- })- .unwrap_or_default();+ DelegationDispatchKind::Collapsed { targets } => {+ let targets = match targets {+ Ok(targets) => targets,+ Err(reason) => {+ return Ok(ToolResult::error(format!(+ "delegate_to: invalid advertised target mapping: {reason}"+ )));+ }+ };super::collapsed_delegation::execute_collapsed_delegation(- &targets,+ targets,arguments,Some(&tool_context),child,diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rsindex 1254dd42e6..6488b1e898 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rs@@ -3,6 +3,9 @@ use async_trait::async_trait;use std::sync::Arc;use tinytools::Tool;+use super::super::collapsed_delegation::{+ dispatch_targets_from_schema, CollapsedDelegationTool, DelegateTarget,+};use crate::agent::tools::AskClarificationTool;struct DelegationRegistrationTool {@@ -31,6 +34,14 @@ impl Tool for DelegationRegistrationTool {#[test]fn typed_dispatch_registration_recognises_every_synthesised_delegate_surface() {+ let collapsed: Arc<dyn Tool> = Arc::new(+ CollapsedDelegationTool::for_targets(vec![DelegateTarget {+ tool_name: "research".to_string(),+ agent_id: "researcher".to_string(),+ description: "Research the request.".to_string(),+ }])+ .expect("one collapsed target is routable"),+ );let integration = Arc::new(DelegationRegistrationTool {name: "delegate_to_integrations_agent",parameters: serde_json::json!({@@ -38,10 +49,7 @@ fn typed_dispatch_registration_recognises_every_synthesised_delegate_surface() {}),});for tool in [- Arc::new(DelegationRegistrationTool {- name: "delegate_to",- parameters: serde_json::json!({}),- }) as Arc<dyn Tool>,+ collapsed,Arc::new(DelegationRegistrationTool {name: "delegate_researcher",parameters: serde_json::json!({}),@@ -55,6 +63,45 @@ fn typed_dispatch_registration_recognises_every_synthesised_delegate_surface() {}}+#[test]+fn collapsed_dispatch_mapping_has_exact_advertised_vocabulary_and_rejects_drift() {+ let tool = CollapsedDelegationTool::for_targets(vec![+ DelegateTarget {+ tool_name: "research".to_string(),+ agent_id: "researcher".to_string(),+ description: "Research the request.".to_string(),+ },+ DelegateTarget {+ tool_name: "review".to_string(),+ agent_id: "code_reviewer".to_string(),+ description: "Review code.".to_string(),+ },+ ])+ .expect("targets are routable");+ let mut schema = tool.parameters_schema();+ let targets = dispatch_targets_from_schema(&schema).expect("collapsed dispatch target mapping");+ assert_eq!(+ targets,+ vec![+ DelegateTarget {+ tool_name: "research".to_string(),+ agent_id: "researcher".to_string(),+ description: String::new(),+ },+ DelegateTarget {+ tool_name: "review".to_string(),+ agent_id: "code_reviewer".to_string(),+ description: String::new(),+ },+ ]+ );++ schema["properties"]["agent"]["enum"] = serde_json::json!(["research", "unadvertised"]);+ let error = dispatch_targets_from_schema(&schema)+ .expect_err("a selector absent from the concrete target map must be rejected");+ assert!(error.contains("exactly match"), "{error}");+}+#[test]fn ask_clarification_tool_re_exported() {let tool = AskClarificationTool::new();diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rsindex 4dc22dec0a..e5426f24b6 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs@@ -105,6 +105,7 @@ impl SpawnAsyncSubagentTool {let progress_sink = parent.on_progress.clone();let parent_thread_id = tool_context.and_then(ToolRunContext::thread_id)+ .or(run_context.thread_id.as_deref()).map(str::to_owned);// Async delivery is thread-addressed: the finished result is inserted@@ -140,7 +141,9 @@ impl SpawnAsyncSubagentTool {));}let store = SubagentSessionStore::new(parent.workspace_dir.clone());- let workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned());+ let workspace_descriptor = tool_context+ .and_then(|ctx| ctx.workspace().cloned())+ .or_else(|| run_context.workspace.clone());let effective_action_root = workspace_descriptor.as_ref().map(|workspace| {diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rsindex d825ca573c..08cf152dc0 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs@@ -392,6 +392,7 @@ impl SpawnSubagentTool {// `dispatch.rs::dispatch_subagent`.let parent_thread_id = tool_context.and_then(ToolRunContext::thread_id)+ .or(run_context.thread_id.as_deref()).map(str::to_owned);let has_delivery_thread = parent_thread_id.is_some();if !blocking && !has_delivery_thread {@@ -422,7 +423,7 @@ impl SpawnSubagentTool {"[spawn_subagent] routing to reusable async sub-agent by default");return super::spawn_async_subagent::SpawnAsyncSubagentTool::new()- .execute_with_context(async_args, ToolCallOptions::default(), tool_context)+ .execute_with_parent_context(async_args, tool_context, run_context).await;}diff --git a/scripts/ci/agent-runtime-boundary-baseline.json b/scripts/ci/agent-runtime-boundary-baseline.jsonindex 1fda13147c..8a6b428d2d 100644--- a/scripts/ci/agent-runtime-boundary-baseline.json+++ b/scripts/ci/agent-runtime-boundary-baseline.json@@ -37,7 +37,7 @@{"rule": "openhuman-runtime-bridge","path": "crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/dispatch.rs",- "line": 270,+ "line": 279,"text": "let run_result = Box::pin(run_turn_via_tinyagents_shared(","occurrence": 1},@@ -216,20 +216,6 @@"text": "let Some(thread_id) = current_thread_id() else {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/goals/tools.rs",- "line": 22,- "text": "use crate::agent::tinyagents::thread_context::current_thread_id;",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/goals/tools.rs",- "line": 40,- "text": "current_thread_id().ok_or_else(|| {",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/harness/fork_context.rs",@@ -552,20 +538,6 @@"text": "pub(crate) fn current_spawn_depth() -> usize {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/harness/subagent_runner/extract_tool.rs",- "line": 589,- "text": "thread_id: crate::agent::tinyagents::thread_context::current_thread_id(),",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/harness/subagent_runner/ops/graph/transcript.rs",- "line": 99,- "text": "thread_id: crate::agent::tinyagents::thread_context::current_thread_id(),",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/harness/subagent_runner/ops/mod.rs",@@ -632,7 +604,7 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs",- "line": 1729,+ "line": 1733,"text": "crate::agent::harness::turn_subagent_usage::record_subagent_usage(","occurrence": 1},@@ -751,14 +723,21 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/delegation.rs",- "line": 141,+ "line": 107,+ "text": "run_context.parent = current_parent();",+ "occurrence": 1+ },+ {+ "rule": "openhuman-task-local",+ "path": "crates/openhuman-core/src/agent/orchestration/delegation.rs",+ "line": 153,"text": "if current_parent().is_some() {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/delegation.rs",- "line": 147,+ "line": 159,"text": "with_parent_context(parent, run).await","occurrence": 1},@@ -772,21 +751,21 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/ops.rs",- "line": 401,+ "line": 417,"text": "let handle = tokio::spawn(crate::agent::turn_origin::propagate(","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/ops.rs",- "line": 402,+ "line": 418,"text": "crate::agent::turn_workspace::propagate(async move {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/ops.rs",- "line": 404,+ "line": 420,"text": "let result = with_parent_context(parent, async move {","occurrence": 1},@@ -814,7 +793,7 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs",- "line": 53,+ "line": 61,"text": "let parent = match current_parent() {","occurrence": 1},@@ -828,49 +807,42 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs",- "line": 11,- "text": "use crate::agent::tinyagents::thread_context::current_thread_id;",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs",- "line": 258,+ "line": 267,"text": "let parent_session = current_parent()","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs",- "line": 261,+ "line": 270,"text": "let progress_sink = current_parent().and_then(|p| p.on_progress.clone());","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs",- "line": 396,- "text": "if let (Some(parent), Some(thread_id)) = (current_parent(), current_thread_id()) {",+ "line": 407,+ "text": "if let (Some(parent), Some(thread_id)) = (current_parent(), thread_id) {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs",- "line": 7,+ "line": 8,"text": "use crate::agent::harness::fork_context::{current_agent_context_prepared_sources, current_parent};","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs",- "line": 50,+ "line": 82,"text": "let Some(parent) = current_parent() else {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs",- "line": 197,+ "line": 245,"text": "let prepared_sources = current_agent_context_prepared_sources();","occurrence": 1},@@ -884,17 +856,10 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/close_subagent.rs",- "line": 64,+ "line": 74,"text": "let parent = match current_parent() {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/close_subagent.rs",- "line": 73,- "text": "let parent_thread_id = crate::agent::tinyagents::thread_context::current_thread_id();",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs",@@ -905,66 +870,10 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs",- "line": 217,+ "line": 269,"text": "let parent = match current_parent() {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 4,- "text": "use crate::agent::harness::fork_context::current_parent;",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 57,- "text": "let parent_ctx = current_parent();",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 83,- "text": "crate::agent::harness::turn_attachments_context::current_turn_image_placeholders();",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 122,- "text": "crate::agent::tinyagents::thread_context::current_thread_id().is_some();",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 191,- "text": "if let Some(progress) = current_parent().and_then(|p| p.on_progress.clone()) {",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 271,- "text": "if let Some(progress) = current_parent().and_then(|p| p.on_progress.clone()) {",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 316,- "text": "if let Some(progress) = current_parent().and_then(|p| p.on_progress.clone()) {",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs",- "line": 380,- "text": "if let Some(progress) = current_parent().and_then(|p| p.on_progress.clone()) {",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs",@@ -975,59 +884,38 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs",- "line": 52,+ "line": 62,"text": "let parent = match current_parent() {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs",- "line": 60,- "text": "let parent_thread_id = crate::agent::tinyagents::thread_context::current_thread_id();",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- "line": 56,+ "line": 57,"text": "let parent = match current_parent() {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- "line": 106,- "text": "crate::agent::tinyagents::thread_context::current_thread_id();",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- "line": 425,+ "line": 428,"text": "let join = tokio::spawn(crate::agent::turn_origin::propagate(","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- "line": 426,+ "line": 429,"text": "crate::agent::turn_workspace::propagate(async move {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- "line": 441,+ "line": 446,"text": "let result = with_parent_context(background_parent, async move {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- "line": 442,- "text": "crate::agent::tinyagents::thread_context::with_thread_id(",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs",@@ -1038,63 +926,49 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 188,+ "line": 204,"text": "if let Some(parent_ctx) = current_parent() {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 225,+ "line": 241,"text": "let parent_ctx = current_parent();","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 378,- "text": "crate::agent::tinyagents::thread_context::current_thread_id().is_some();",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 412,+ "line": 431,"text": "let parent_session = current_parent()","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 422,+ "line": 441,"text": "let worker_thread_id = current_parent().and_then(|p| {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 424,- "text": "crate::agent::tinyagents::thread_context::current_thread_id()?;",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 449,+ "line": 467,"text": "if let Some(progress) = current_parent().and_then(|p| p.on_progress.clone()) {","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 492,+ "line": 512,"text": "let progress_sink = current_parent().and_then(|p| p.on_progress.clone());","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- "line": 572,+ "line": 592,"text": "let workspace_dir = current_parent()","occurrence": 1},@@ -1115,17 +989,10 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs",- "line": 152,+ "line": 203,"text": "let parent = current_parent().ok_or_else(|| anyhow::anyhow!(\"no parent context\"))?;","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs",- "line": 156,- "text": "let current_thread_id = crate::agent::tinyagents::thread_context::current_thread_id()",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs",@@ -1245,13 +1112,6 @@"text": "crate::agent::tinyagents::thread_context::with_thread_id(thread_id.to_string(), run)","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/tinyagents/host/agent_memory.rs",- "line": 360,- "text": "let current_thread_id_ref = crate::agent::tinyagents::thread_context::current_thread_id();",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/tinyagents/host/run_context.rs",@@ -1336,34 +1196,13 @@"text": "crate::agent::tinyagents::thread_context::with_thread_id(run_thread_id, async move {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/tools/delegate_to_personality.rs",- "line": 4,- "text": "use crate::agent::harness::fork_context::current_parent;",- "occurrence": 1- },- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/tools/delegate_to_personality.rs",- "line": 106,- "text": "let parent_ctx = match current_parent() {",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/tools/todo.rs",- "line": 201,+ "line": 210,"text": "let Some(parent) = crate::agent::harness::fork_context::current_parent() else {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/agent/tools/todo.rs",- "line": 213,- "text": "let Some(thread_id) = thread_context::current_thread_id() else {",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/agent/tools/update_task.rs",@@ -1791,13 +1630,6 @@"text": "if let Err(e) = with_origin(origin, apply_decision(run, &envelope)).await {","occurrence": 1},- {- "rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/memory/tools/search/hybrid_search.rs",- "line": 261,- "text": "let exclude_session_id = crate::agent::tinyagents::thread_context::current_thread_id();",- "occurrence": 1- },{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/platform/socket/medulla/mod.rs",