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(turn_state): backfill child tool arguments from the completion event\n\nPersisting only what `SubagentToolCallStarted` carries fixed the wrong half\nof #5987. On the tinyagents path — the ordinary sub-agent tool, and the case\nthe issue was reported against — that event's `arguments` is always\n`Value::Null`; the captured input arrives with `SubagentToolCallCompleted`,\nas `SubagentToolCallCompleted::arguments` documents. Only paths that know\ntheir arguments upfront (unknown-tool calls) were actually fixed.\n\nBackfill the call row from the completion payload when the start event left\nit empty. Arguments captured at start stay authoritative, so a completion\ncannot rewrite the input a row was invoked with.\n\nAlso corrects two comments that read `Value::Null` as "this call had no\ninput". It is not — it is "not known yet", which is precisely why the\nbackfill is needed, and describing it the other way is what made the gap\nlook intentional.\n\nFound in review by Codex on #5998.\n
Shanu137e2b9bb91e
diff --git a/src/openhuman/threads/turn_state/mirror_part_01.rs b/src/openhuman/threads/turn_state/mirror_part_01.rsindex b5cd943002..a0f112ed42 100644--- a/src/openhuman/threads/turn_state/mirror_part_01.rs+++ b/src/openhuman/threads/turn_state/mirror_part_01.rs@@ -90,9 +90,12 @@ fn cap_persisted_output(output: &str) -> Option<String> {}/// Cap `arguments` for snapshot persistence. Returns `None` for a null-/// payload — the observability bridge emits `Value::Null` on the paths where-/// the child's arguments were never materialised, and a null would otherwise-/// persist as a meaningless "Input: null" row.+/// payload, which would otherwise persist as a meaningless "Input: null" row.+///+/// A null is not the same as "this call had no input": on the tinyagents path+/// the *started* event always carries `Value::Null` and the captured arguments+/// only arrive with `SubagentToolCallCompleted`, so the completion arm+/// backfills what this returns `None` for at start.////// A payload that serialises within [`MAX_PERSISTED_TOOL_ARGS`] is kept/// verbatim, so the rehydrated row renders the same structured input the livediff --git a/src/openhuman/threads/turn_state/mirror_part_02.rs b/src/openhuman/threads/turn_state/mirror_part_02.rsindex c6019255b4..ae9ea91298 100644--- a/src/openhuman/threads/turn_state/mirror_part_02.rs+++ b/src/openhuman/threads/turn_state/mirror_part_02.rs@@ -285,6 +285,7 @@ impl TurnStateMirror {success,output,output_chars,+ arguments,elapsed_ms,failure,..@@ -310,6 +311,19 @@ impl TurnStateMirror {// keeps its explanation across a round-trip (#4459).call.failure = persisted_failure;call.output = cap_persisted_output(output);+ // Backfill the input on the tinyagents path, where+ // the *started* event carries `Value::Null` and the+ // captured arguments only reach us here (see+ // `SubagentToolCallCompleted::arguments`). Without+ // this the ordinary sub-agent tool — the common+ // case — still rehydrates with no input (#5987).+ // Only fills a gap: a start event that already+ // supplied arguments stays authoritative.+ if call.args.is_none() {+ if let Some(arguments) = arguments {+ call.args = cap_persisted_args(arguments);+ }+ }}// Keep the transcript's Tool item in lockstep so the// rehydrated row shows the terminal status + timing.diff --git a/src/openhuman/threads/turn_state/mirror_tests_part_02_tests.rs b/src/openhuman/threads/turn_state/mirror_tests_part_02_tests.rsindex f527044b00..1f99827099 100644--- a/src/openhuman/threads/turn_state/mirror_tests_part_02_tests.rs+++ b/src/openhuman/threads/turn_state/mirror_tests_part_02_tests.rs@@ -261,11 +261,12 @@ fn subagent_tool_call_persists_its_arguments() {);}-/// The observability bridge emits `Value::Null` on the paths where a child's-/// arguments were never materialised. Persisting that would render a-/// meaningless "Input: null" row, so it must serialize away entirely.+/// A `Value::Null` payload must serialize away rather than persist a+/// meaningless "Input: null" row. This is the state *at start* on the+/// tinyagents path; the arguments arrive later and are backfilled by+/// `tinyagents_path_backfills_arguments_from_the_completion_event`.#[test]-fn null_child_arguments_are_not_persisted() {+fn null_child_arguments_are_not_persisted_at_start() {let (_d, mut m) = fresh("t");m.observe(&AgentProgress::SubagentSpawned {agent_id: "researcher".into(),@@ -378,3 +379,110 @@ fn legacy_subagent_tool_call_without_args_deserializes() {assert_eq!(call.call_id, "c1");assert_eq!(call.output.as_deref(), Some("3 hits"));}++/// The ordinary sub-agent tool path — the common case, and the one #5987 was+/// actually reported against. `observability_part_02.rs` emits+/// `SubagentToolCallStarted.arguments` as `Value::Null` there and only supplies+/// the captured input on `SubagentToolCallCompleted.arguments`, so persisting+/// the start event alone leaves these calls with no input after a reload.+#[test]+fn tinyagents_path_backfills_arguments_from_the_completion_event() {+ let (_d, mut m) = fresh("t");+ m.observe(&AgentProgress::SubagentSpawned {+ agent_id: "researcher".into(),+ task_id: "sub-1".into(),+ mode: "typed".into(),+ dedicated_thread: false,+ prompt_chars: 10,+ prompt: String::new(),+ worker_thread_id: None,+ display_name: Some("Researcher".into()),+ });+ // Start carries no arguments — exactly what the tinyagents bridge sends.+ m.observe(&AgentProgress::SubagentToolCallStarted {+ agent_id: "researcher".into(),+ task_id: "sub-1".into(),+ call_id: "c1".into(),+ tool_name: "web_search".into(),+ arguments: serde_json::Value::Null,+ iteration: 1,+ display_label: Some("Searching the web".into()),+ display_detail: None,+ });+ m.observe(&AgentProgress::SubagentToolCallCompleted {+ agent_id: "researcher".into(),+ task_id: "sub-1".into(),+ call_id: "c1".into(),+ tool_name: "web_search".into(),+ success: true,+ output_chars: 6,+ output: "3 hits".into(),+ arguments: Some(serde_json::json!({ "query": "latest rust release" })),+ elapsed_ms: 12,+ iteration: 1,+ failure: None,+ });++ let activity = m.snapshot().tool_timeline[0]+ .subagent+ .as_ref()+ .expect("activity")+ .clone();+ assert_eq!(+ activity.tool_calls[0].args,+ Some(serde_json::json!({ "query": "latest rust release" })),+ "completion arguments must backfill a call the start event left empty"+ );+}++/// The backfill only fills a gap. A start event that already supplied the+/// arguments stays authoritative, so a completion payload cannot rewrite the+/// input the row was actually invoked with.+#[test]+fn completion_arguments_do_not_overwrite_arguments_captured_at_start() {+ let (_d, mut m) = fresh("t");+ m.observe(&AgentProgress::SubagentSpawned {+ agent_id: "researcher".into(),+ task_id: "sub-1".into(),+ mode: "typed".into(),+ dedicated_thread: false,+ prompt_chars: 10,+ prompt: String::new(),+ worker_thread_id: None,+ display_name: Some("Researcher".into()),+ });+ m.observe(&AgentProgress::SubagentToolCallStarted {+ agent_id: "researcher".into(),+ task_id: "sub-1".into(),+ call_id: "c1".into(),+ tool_name: "web_search".into(),+ arguments: serde_json::json!({ "query": "from start" }),+ iteration: 1,+ display_label: Some("Searching the web".into()),+ display_detail: None,+ });+ m.observe(&AgentProgress::SubagentToolCallCompleted {+ agent_id: "researcher".into(),+ task_id: "sub-1".into(),+ call_id: "c1".into(),+ tool_name: "web_search".into(),+ success: true,+ output_chars: 6,+ output: "3 hits".into(),+ arguments: Some(serde_json::json!({ "query": "from completion" })),+ elapsed_ms: 12,+ iteration: 1,+ failure: None,+ });++ let activity = m.snapshot().tool_timeline[0]+ .subagent+ .as_ref()+ .expect("activity")+ .clone();+ assert_eq!(+ activity.tool_calls[0].args,+ Some(serde_json::json!({ "query": "from start" })),+ "arguments captured at start must not be rewritten on completion"+ );+}diff --git a/src/openhuman/threads/turn_state/types.rs b/src/openhuman/threads/turn_state/types.rsindex 02b442bf3e..9cb015681e 100644--- a/src/openhuman/threads/turn_state/types.rs+++ b/src/openhuman/threads/turn_state/types.rs@@ -199,8 +199,12 @@ pub struct SubagentToolCall {/// row shows *what* the sub-agent did and not just which tool it reached/// for (#5987). Mirrors the live `subagent_tool_call` event's `args`/// verbatim when it fits the cap; an oversized payload degrades to a- /// truncated string. `None` when the child's arguments were never- /// materialised and on legacy snapshots.+ /// truncated string. Taken from the started event when it carries the+ /// arguments, otherwise backfilled from+ /// [`AgentProgress::SubagentToolCallCompleted::arguments`] — the tinyagents+ /// path emits `Value::Null` at start and only captures the input on+ /// completion. `None` when the harness captured no input at all+ /// (`PayloadCapture::tool_io` off) and on legacy snapshots.////// Deliberately absent from [`SubagentTranscriptItem::Tool`]: like/// `output` and `failure`, this is a heavy payload that lives once on the