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): keep a content-returning action on the Gmail sub-agent surface\n\nAsking the agent to read Gmail through `delegate_to_integrations_agent`\ncame back with no email content. Three defects stacked up.\n\nThe fuzzy ranker derives an intent verb from the prompt and drops every\ntool whose own name-verb conflicts with it. `FETCH`/`GET` are the `Read`\nverb and `find`/`search` are `List`, so "find job opportunities from the\nlast 5 days" removed `GMAIL_FETCH_EMAILS` and both\n`GMAIL_FETCH_MESSAGE_BY_*` before scoring began; a flat verb-alignment\nbonus then let zero-overlap tools fill the budget, leaving twelve\n`GMAIL_LIST_*` actions that return ids and settings and nothing that\nreturns a message body.\n\n- `TOOLKIT_ESSENTIAL_ACTIONS` reserves a toolkit's must-have actions\n **inside** the existing top-K budget — essentials first, ranked hits\n after, deduplicated and truncated — so the surface can no longer lose\n its only content-returning action. It never appends past `top_k`:\n `TOOL_FILTER_TOP_K_HEAVY` exists because Gmail at top-K=25 produced a\n 276k-token first-iteration prompt. Only Gmail is seeded.\n- A `Completed` sub-agent whose output is only tool-call markup is now\n framed with the `[SUBAGENT_INCOMPLETE]` envelope instead of being\n passed through as a finished answer (#4096 precedent). The marker\n vocabulary stays in one place: the archivist's\n `looks_like_unexecuted_tool_call`, which its own strip now uses.\n- Blocking delegations register no worker, but the orchestrator's\n `[active_subagents]` guidance tells it to collect completed work with\n `wait_subagent`. The result now says it ran inline and there is no\n worker to wait for.\n- The narrowed surface logs the action names it kept, not just a count.\n\nCloses #6033\n
Shanu50b6ee13b94f
diff --git a/src/openhuman/agent/harness/archivist/helpers.rs b/src/openhuman/agent/harness/archivist/helpers.rsindex 531b39298b..4ef54ee11b 100644--- a/src/openhuman/agent/harness/archivist/helpers.rs+++ b/src/openhuman/agent/harness/archivist/helpers.rs@@ -4,6 +4,18 @@ use std::collections::hash_map::RandomState;use std::hash::{BuildHasher, Hasher};use std::time::{SystemTime, UNIX_EPOCH};+/// Whether `text` carries tool-call markup rather than (only) prose.+///+/// This is the single place the marker vocabulary is written down. The+/// archivist uses it to decide whether stripping is needed at all; the+/// delegation return path uses it to notice a sub-agent that emitted a+/// tool call instead of executing one (#6033).+pub(crate) fn looks_like_unexecuted_tool_call(text: &str) -> bool {+ text.contains("<tool_call>")+ || text.contains("{\"tool_calls\"")+ || text.contains("\"tool_use\"")+}+/// Strip tool-call JSON blocks from an assistant response, leaving only the/// prose text.///@@ -17,13 +29,10 @@ use std::time::{SystemTime, UNIX_EPOCH};/// raw JSON objects that begin with `{"tool_calls":`. The output may be empty/// if the entire response was tool-call markup — callers should handle that/// case (empty text → no-op ingest).-pub(super) fn strip_tool_calls_from_response(response: &str) -> String {+pub(crate) fn strip_tool_calls_from_response(response: &str) -> String {// Fast path: if the response contains no obvious tool-call markers, return// it unchanged to avoid unnecessary allocation.- if !response.contains("<tool_call>")- && !response.contains("{\"tool_calls\"")- && !response.contains("\"tool_use\"")- {+ if !looks_like_unexecuted_tool_call(response) {return response.to_string();}diff --git a/src/openhuman/agent/harness/archivist/mod.rs b/src/openhuman/agent/harness/archivist/mod.rsindex def3af3aef..89d4ae1462 100644--- a/src/openhuman/agent/harness/archivist/mod.rs+++ b/src/openhuman/agent/harness/archivist/mod.rs@@ -18,7 +18,7 @@pub mod boundary;mod events_heuristic;-mod helpers;+pub(crate) mod helpers;mod hook_impl;mod lifecycle;mod recap;diff --git a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs b/src/openhuman/agent/harness/subagent_runner/ops/runner.rsindex b2163356fe..9a4a1da1ae 100644--- a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs+++ b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs@@ -32,7 +32,7 @@ use crate::openhuman::agent::harness::subagent_runner::handoff::ResultHandoffCacuse crate::openhuman::agent::harness::subagent_runner::subagent_iter_cap_with_autonomous_lift;use crate::openhuman::agent::harness::subagent_runner::tool_prep::{build_text_mode_tool_instructions, filter_tool_indices, is_subagent_spawn_tool,- load_prompt_source, top_k_for_toolkit,+ load_prompt_source, select_actions_with_essentials, top_k_for_toolkit,};use crate::openhuman::agent::harness::subagent_runner::types::{SubagentMode, SubagentRunError, SubagentRunOptions, SubagentRunOutcome, SubagentRunStatus,@@ -1072,15 +1072,26 @@ async fn run_typed_mode(let selected: Vec<&crate::openhuman::agent::context::prompt::ConnectedIntegrationTool,> = if filter_hits.len() >= super::super::super::tool_filter::MIN_CONFIDENT_HITS {+ // The ranker's verb gate can drop every content-returning+ // action for a find/search prompt, so the toolkit's+ // essentials are reserved inside the same budget (#6033).+ let kept_idx =+ select_actions_with_essentials(tk, &integration.tools, &filter_hits, top_k);+ let kept: Vec<_> = kept_idx.iter().map(|&i| &integration.tools[i]).collect();tracing::info!(agent_id = %definition.id,toolkit = %tk,total = integration.tools.len(),- kept = filter_hits.len(),+ kept = kept.len(),top_k = top_k,+ kept_actions = %kept+ .iter()+ .map(|a| a.name.as_str())+ .collect::<Vec<_>>()+ .join(","),"[subagent_runner:typed] fuzzy tool filter narrowed toolkit");- filter_hits.iter().map(|&i| &integration.tools[i]).collect()+ kept} else {tracing::info!(agent_id = %definition.id,diff --git a/src/openhuman/agent/harness/subagent_runner/tool_prep.rs b/src/openhuman/agent/harness/subagent_runner/tool_prep.rsindex 565ab3d996..756708bf03 100644--- a/src/openhuman/agent/harness/subagent_runner/tool_prep.rs+++ b/src/openhuman/agent/harness/subagent_runner/tool_prep.rs@@ -36,6 +36,39 @@ const HEAVY_SCHEMA_TOOLKITS: &[&str] = &[const TOOL_FILTER_TOP_K_DEFAULT: usize = 25;const TOOL_FILTER_TOP_K_HEAVY: usize = 12;+/// Actions a toolkit must keep on the sub-agent's surface even when the+/// fuzzy ranker does not pick them.+///+/// The ranker (`tinyagents_harness::tool::select`) derives an intent verb+/// from the prompt and then **drops** every tool whose own name-verb+/// conflicts with it. `FETCH`/`GET` are the `Read` verb and `find`/`search`+/// are `List`, so a plain "find the emails about X" prompt removes+/// `GMAIL_FETCH_EMAILS` and both `GMAIL_FETCH_MESSAGE_BY_*` before scoring+/// even starts. A flat verb-alignment bonus then lets zero-overlap tools+/// fill the budget, so the surviving surface can be twelve `GMAIL_LIST_*`+/// actions — ids and settings, nothing that returns a message body. The+/// sub-agent burns its iterations and answers without the email (#6033).+///+/// These names are **reserved inside** the top-K budget, never appended+/// past it: [`TOOL_FILTER_TOP_K_HEAVY`] exists because Gmail at top-K=25+/// produced a 276k-token first-iteration prompt, so an essential displaces+/// the lowest-ranked hit rather than growing the surface.+///+/// Only Gmail is seeded, deliberately. A wrong entry spends a slot on+/// every prompt for that toolkit, so add one only with a fixture-backed+/// repro — the ranker's general behaviour is the upstream fix.+const TOOLKIT_ESSENTIAL_ACTIONS: &[(&str, &[&str])] = &[(+ "gmail",+ &[+ // The only action that returns message *content* for a search.+ "GMAIL_FETCH_EMAILS",+ // The follow-up once `GMAIL_LIST_MESSAGES` has handed back bare ids.+ "GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID",+ // Keeps the write path reachable when a read prompt wins the ranking.+ "GMAIL_SEND_EMAIL",+ ],+)];+/// Pick a top-K budget for the fuzzy filter based on how dense the/// toolkit's action schemas tend to be. Match is case-insensitive so/// we don't care whether the caller passed `"Gmail"` or `"gmail"`.@@ -50,6 +83,78 @@ pub(super) fn top_k_for_toolkit(toolkit: &str) -> usize {}}+/// Actions [`TOOLKIT_ESSENTIAL_ACTIONS`] reserves for `toolkit`, or an+/// empty slice when the toolkit has no entry. Case-insensitive, matching+/// [`top_k_for_toolkit`].+pub(super) fn essential_actions_for_toolkit(toolkit: &str) -> &'static [&'static str] {+ TOOLKIT_ESSENTIAL_ACTIONS+ .iter()+ .find(|(name, _)| name.eq_ignore_ascii_case(toolkit))+ .map(|(_, actions)| *actions)+ .unwrap_or(&[])+}++/// Pick the action indices the sub-agent will actually see: the toolkit's+/// essentials first, then the ranker's hits in rank order, deduplicated and+/// truncated to `top_k`.+///+/// An essential that the connected toolkit does not actually expose is+/// skipped rather than guessed at, so a stale table entry costs nothing and+/// can never produce an out-of-range index. A toolkit with no entry returns+/// the ranker's hits unchanged (capped at `top_k`), which is what every+/// call site did before the essentials existed.+pub(super) fn select_actions_with_essentials(+ toolkit: &str,+ actions: &[crate::openhuman::agent::context::prompt::ConnectedIntegrationTool],+ filter_hits: &[usize],+ top_k: usize,+) -> Vec<usize> {+ let essentials = essential_actions_for_toolkit(toolkit);+ if essentials.is_empty() || top_k == 0 {+ return filter_hits.iter().take(top_k).copied().collect();+ }++ let mut selected: Vec<usize> = Vec::with_capacity(top_k.min(actions.len()));+ let mut reserved: Vec<&str> = Vec::new();+ for essential in essentials {+ if selected.len() >= top_k {+ break;+ }+ let found = actions+ .iter()+ .position(|a| a.name.eq_ignore_ascii_case(essential));+ if let Some(idx) = found {+ if !selected.contains(&idx) {+ selected.push(idx);+ reserved.push(essential);+ }+ }+ }++ let ranked_before = filter_hits.len().min(top_k);+ for &idx in filter_hits {+ if selected.len() >= top_k {+ break;+ }+ if !selected.contains(&idx) {+ selected.push(idx);+ }+ }++ // A reserved action the ranker had already chosen costs nothing; the+ // rest displace the lowest-ranked hits that no longer fit.+ let ranked_kept = filter_hits.iter().filter(|i| selected.contains(i)).count();+ tracing::debug!(+ toolkit = %toolkit,+ reserved = %reserved.join(","),+ kept = selected.len(),+ top_k = top_k,+ dropped_ranked = ranked_before.saturating_sub(ranked_kept),+ "[subagent_runner:tools] reserved essential actions inside the top-K budget"+ );+ selected+}+// ── Text-mode protocol block ────────────────────────────────────────────/// Format the tool-use protocol block appended to the system prompt in textdiff --git a/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs b/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rsindex 5610c74e28..012b5f1aaf 100644--- a/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs+++ b/src/openhuman/agent/harness/subagent_runner/tool_prep_tests.rs@@ -55,3 +55,232 @@ fn unprefixed_delegate_name_overrides_are_treated_as_spawn_tools() {);}}++// ── Essential-action reservation (#6033) ────────────────────────────────++use crate::openhuman::agent::context::prompt::ConnectedIntegrationTool;++fn action(name: &str) -> ConnectedIntegrationTool {+ ConnectedIntegrationTool {+ name: name.to_string(),+ description: format!("{name} description"),+ parameters: None,+ }+}++/// The catalogue the ranker sees for Gmail in the failing case: every+/// content-returning action gated out, twelve `LIST_*` slots kept.+fn gmail_catalogue() -> Vec<ConnectedIntegrationTool> {+ [+ "GMAIL_LIST_CSE_IDENTITIES",+ "GMAIL_LIST_DRAFTS",+ "GMAIL_LIST_LABELS",+ "GMAIL_LIST_MESSAGES",+ "GMAIL_LIST_THREADS",+ "GMAIL_FETCH_EMAILS",+ "GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID",+ "GMAIL_SEND_EMAIL",+ ]+ .iter()+ .map(|n| action(n))+ .collect()+}++#[test]+fn essentials_are_reserved_ahead_of_ranked_hits() {+ let actions = gmail_catalogue();+ // The ranker picked only LIST_* actions — the #6033 repro.+ let hits = vec![0, 1, 2, 3, 4];+ let selected = select_actions_with_essentials("gmail", &actions, &hits, 12);+ let names: Vec<&str> = selected.iter().map(|&i| actions[i].name.as_str()).collect();++ assert_eq!(+ &names[..3],+ &[+ "GMAIL_FETCH_EMAILS",+ "GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID",+ "GMAIL_SEND_EMAIL"+ ],+ "essentials come first, in table order"+ );+ assert!(+ names.contains(&"GMAIL_LIST_MESSAGES"),+ "ranked hits still follow the essentials"+ );+}++#[test]+fn an_essential_the_ranker_already_picked_costs_no_extra_slot() {+ let actions = gmail_catalogue();+ // Index 5 is GMAIL_FETCH_EMAILS — already ranked.+ let hits = vec![5, 0, 1];+ let selected = select_actions_with_essentials("gmail", &actions, &hits, 12);++ let fetches = selected+ .iter()+ .filter(|&&i| actions[i].name == "GMAIL_FETCH_EMAILS")+ .count();+ assert_eq!(+ fetches, 1,+ "no duplicate index for an already-ranked essential"+ );+ assert_eq!(+ selected.len(),+ selected+ .iter()+ .collect::<std::collections::HashSet<_>>()+ .len(),+ "selection is duplicate-free"+ );+}++#[test]+fn selection_never_exceeds_the_top_k_budget() {+ let actions = gmail_catalogue();+ let hits: Vec<usize> = (0..actions.len()).collect();+ for top_k in [0_usize, 1, 3, 4, 12] {+ let selected = select_actions_with_essentials("gmail", &actions, &hits, top_k);+ assert!(+ selected.len() <= top_k,+ "top_k={top_k} budget exceeded: {} kept",+ selected.len()+ );+ assert_eq!(+ selected.len(),+ selected+ .iter()+ .collect::<std::collections::HashSet<_>>()+ .len(),+ "top_k={top_k} produced a duplicate index"+ );+ }+}++#[test]+fn an_unlisted_toolkit_is_an_exact_passthrough() {+ let actions: Vec<_> = ["SLACK_SEND_MESSAGE", "SLACK_LIST_CHANNELS"]+ .iter()+ .map(|n| action(n))+ .collect();+ let hits = vec![1, 0];+ assert_eq!(+ select_actions_with_essentials("slack", &actions, &hits, 12),+ hits,+ "a toolkit with no essentials must rank exactly as before"+ );+}++#[test]+fn an_essential_absent_from_the_toolkit_is_skipped_not_guessed() {+ // Connected Gmail exposing none of the essentials: the helper must not+ // invent an index or panic.+ let actions: Vec<_> = ["GMAIL_LIST_LABELS", "GMAIL_LIST_THREADS"]+ .iter()+ .map(|n| action(n))+ .collect();+ let hits = vec![0, 1];+ let selected = select_actions_with_essentials("gmail", &actions, &hits, 12);+ assert_eq!(selected, hits);+ assert!(selected.iter().all(|&i| i < actions.len()));+}++#[test]+fn toolkit_lookup_is_case_insensitive() {+ assert_eq!(+ essential_actions_for_toolkit("Gmail"),+ essential_actions_for_toolkit("gmail")+ );+ assert!(!essential_actions_for_toolkit("GMAIL").is_empty());+ assert!(essential_actions_for_toolkit("slack").is_empty());+}++#[test]+fn every_essential_name_exists_in_the_real_toolkit_fixture() {+ // A stale table entry would silently spend no slot and hide the bug it+ // was added for, so pin the names against the real Composio dump.+ for (toolkit, essentials) in TOOLKIT_ESSENTIAL_ACTIONS {+ let path = format!(+ "{}/tests/fixtures/composio_{}.json",+ env!("CARGO_MANIFEST_DIR"),+ toolkit+ );+ let raw = std::fs::read_to_string(&path)+ .unwrap_or_else(|e| panic!("failed to read fixture {path}: {e}"));+ let parsed: serde_json::Value =+ serde_json::from_str(&raw).unwrap_or_else(|e| panic!("failed to parse {path}: {e}"));+ let names: Vec<String> = parsed+ .pointer("/result/result/tools")+ .and_then(|t| t.as_array())+ .unwrap_or_else(|| panic!("missing /result/result/tools in {path}"))+ .iter()+ .filter_map(|t| {+ t.pointer("/function/name")+ .and_then(|n| n.as_str())+ .map(str::to_string)+ })+ .collect();+ for essential in *essentials {+ assert!(+ names.iter().any(|n| n == essential),+ "{toolkit} essential {essential} is not a real action in {path}"+ );+ }+ }+}++#[test]+fn gmail_read_prompt_keeps_a_content_returning_action() {+ // The two prompts from #6033: the ranker returns twelve LIST_* actions+ // and nothing that returns a message body. After reservation the+ // sub-agent can actually read an email.+ let path = format!(+ "{}/tests/fixtures/composio_gmail.json",+ env!("CARGO_MANIFEST_DIR")+ );+ let raw = std::fs::read_to_string(&path).expect("gmail fixture");+ let parsed: serde_json::Value = serde_json::from_str(&raw).expect("gmail fixture parses");+ let actions: Vec<ConnectedIntegrationTool> = parsed+ .pointer("/result/result/tools")+ .and_then(|t| t.as_array())+ .expect("fixture tools")+ .iter()+ .map(|t| ConnectedIntegrationTool {+ name: t+ .pointer("/function/name")+ .and_then(|n| n.as_str())+ .unwrap_or_default()+ .to_string(),+ description: t+ .pointer("/function/description")+ .and_then(|d| d.as_str())+ .unwrap_or_default()+ .to_string(),+ parameters: t.pointer("/function/parameters").cloned(),+ })+ .collect();++ for prompt in [+ "find job opportunities from the last 5 days",+ "Search the user's Gmail inbox for job opportunity emails from the last 5 days and summarize sender, subject and date",+ ] {+ let hits = crate::openhuman::agent::harness::tool_filter::filter_actions_by_prompt(+ prompt, &actions, 12,+ );+ let selected = select_actions_with_essentials("gmail", &actions, &hits, 12);+ let names: Vec<&str> = selected.iter().map(|&i| actions[i].name.as_str()).collect();++ assert!(+ names.contains(&"GMAIL_FETCH_EMAILS"),+ "prompt {prompt:?} must keep a content-returning action; got {names:?}"+ );+ assert!(selected.len() <= 12, "prompt {prompt:?} exceeded the budget");+ assert_eq!(+ selected.len(),+ selected+ .iter()+ .collect::<std::collections::HashSet<_>>()+ .len(),+ "prompt {prompt:?} produced a duplicate index"+ );+ }+}diff --git a/src/openhuman/agent/orchestration/tools/dispatch.rs b/src/openhuman/agent/orchestration/tools/dispatch.rsindex 31e19e359e..290a9786fe 100644--- a/src/openhuman/agent/orchestration/tools/dispatch.rs+++ b/src/openhuman/agent/orchestration/tools/dispatch.rs@@ -334,7 +334,28 @@ pub(crate) async fn dispatch_subagent(outcome.iterations,outcome.output.chars().count());- Ok(ToolResult::success(outcome.output))+ // A sub-agent that emitted a tool call instead of executing one+ // "completes" with markup where the answer should be. Passing+ // that through reads as a finished result, so frame it the way+ // an iteration-cap stop is framed (#6033, #4096 precedent).+ if is_unexecuted_tool_call_stub(&outcome.output) {+ log::info!(+ "[agent] {} returned an unexecuted tool-call stub (task_id={} output_chars={}) — reframing as incomplete",+ tool_name,+ outcome.task_id,+ outcome.output.chars().count()+ );+ return Ok(ToolResult::success(incomplete_envelope(+ tool_name,+ "returned an unexecuted tool call instead of a result",+ &outcome.output,+ mode,+ )));+ }+ Ok(ToolResult::success(with_inline_result_note(+ outcome.output,+ mode,+ )))}// A stuck halt / iteration-cap stop returns `Incomplete`; frame the// partial progress so the orchestrator can't mistake it for a@@ -376,11 +397,11 @@ pub(crate) async fn dispatch_subagent(outcome.task_id,outcome.iterations,);- Ok(ToolResult::success(format!(- "[SUBAGENT_INCOMPLETE] the {tool_name} sub-agent {reason} and did not \- finish. Below is partial progress only — do NOT report it as done or \- re-run the identical delegation unchanged.\n\nPartial progress:\n{}",- outcome.output+ Ok(ToolResult::success(incomplete_envelope(+ tool_name,+ reason,+ &outcome.output,+ mode,)))}},@@ -467,6 +488,56 @@ fn format_subagent_failure(tool_name: &str, message: &str) -> String {)}+/// Whether a "completed" sub-agent output is only an unexecuted tool call.+///+/// The marker vocabulary lives in+/// [`crate::openhuman::agent::harness::archivist::helpers::looks_like_unexecuted_tool_call`];+/// this adds the second half of the question — that stripping the markup+/// leaves no prose behind. A reply that merely *mentions* a tool call still+/// carries an answer and passes through untouched.+pub(crate) fn is_unexecuted_tool_call_stub(output: &str) -> bool {+ use crate::openhuman::agent::harness::archivist::helpers::{+ looks_like_unexecuted_tool_call, strip_tool_calls_from_response,+ };+ looks_like_unexecuted_tool_call(output)+ && strip_tool_calls_from_response(output).trim().is_empty()+}++/// The sentence appended to a blocking delegation's result.+///+/// Integration delegations run [`DispatchMode::Blocking`] and register no+/// durable worker, but the orchestrator's `[active_subagents]` guidance+/// tells it to collect completed work with `wait_subagent`. Saying so on+/// the result itself stops it hunting for a worker that never existed+/// (#6033).+const INLINE_RESULT_NOTE: &str = "\n\n[INLINE_RESULT] This delegation ran inline and is complete as returned — there is no sub-agent worker for it. Do NOT call wait_subagent, list_subagents or continue_subagent for this delegation.";++/// Append [`INLINE_RESULT_NOTE`] when the dispatch was blocking.+pub(crate) fn with_inline_result_note(output: String, mode: DispatchMode) -> String {+ if mode == DispatchMode::Blocking {+ format!("{output}{INLINE_RESULT_NOTE}")+ } else {+ output+ }+}++/// The partial-progress envelope shared by every non-finishing outcome.+pub(crate) fn incomplete_envelope(+ tool_name: &str,+ reason: &str,+ output: &str,+ mode: DispatchMode,+) -> String {+ with_inline_result_note(+ format!(+ "[SUBAGENT_INCOMPLETE] the {tool_name} sub-agent {reason} and did not \+ finish. Below is partial progress only — do NOT report it as done or \+ re-run the identical delegation unchanged.\n\nPartial progress:\n{output}"+ ),+ mode,+ )+}+#[cfg(test)]#[path = "dispatch_tests.rs"]mod tests;diff --git a/src/openhuman/agent/orchestration/tools/dispatch_tests.rs b/src/openhuman/agent/orchestration/tools/dispatch_tests.rsindex 66d89b060e..cc90228432 100644--- a/src/openhuman/agent/orchestration/tools/dispatch_tests.rs+++ b/src/openhuman/agent/orchestration/tools/dispatch_tests.rs@@ -205,3 +205,65 @@ fn the_question_in_an_unpersisted_pause_failure_is_encoded_not_interpolated() {"the question should appear JSON-escaped rather than raw: {out}");}++// ── Unexecuted tool-call stubs + inline-result framing (#6033) ──────────++#[test]+fn a_tool_call_stub_is_recognised_as_unexecuted() {+ assert!(super::is_unexecuted_tool_call_stub(+ "<tool_call>{\"name\": \"GMAIL_LIST_MESSAGES\", \"arguments\": {}}</tool_call>"+ ));+ assert!(super::is_unexecuted_tool_call_stub(+ "{\"tool_calls\": [{\"name\": \"GMAIL_FETCH_EMAILS\"}]}"+ ));+}++#[test]+fn a_real_answer_that_mentions_a_tool_call_is_not_a_stub() {+ assert!(!super::is_unexecuted_tool_call_stub(+ "I found 3 job emails. I used <tool_call>GMAIL_FETCH_EMAILS</tool_call> to read them."+ ));+ assert!(!super::is_unexecuted_tool_call_stub(+ "Here are the emails from the last 5 days: Acme, Globex, Initech."+ ));+ assert!(+ !super::is_unexecuted_tool_call_stub(""),+ "empty output carries no markup, so it is not a stub"+ );+}++#[test]+fn a_blocking_delegation_says_its_result_is_inline() {+ let framed = super::with_inline_result_note(+ "the emails are …".to_string(),+ super::DispatchMode::Blocking,+ );+ assert!(framed.starts_with("the emails are …"));+ assert!(framed.contains("[INLINE_RESULT]"));+ assert!(framed.contains("no sub-agent worker"));+ assert!(framed.contains("wait_subagent"));+}++#[test]+fn an_async_delegation_keeps_its_output_untouched() {+ let output = "the emails are …".to_string();+ assert_eq!(+ super::with_inline_result_note(output.clone(), super::DispatchMode::PreferAsync),+ output,+ "only a blocking dispatch may claim there is no worker"+ );+}++#[test]+fn the_incomplete_envelope_frames_a_stub_without_claiming_success() {+ let envelope = super::incomplete_envelope(+ "delegate_to_integrations_agent",+ "returned an unexecuted tool call instead of a result",+ "<tool_call>GMAIL_LIST_MESSAGES</tool_call>",+ super::DispatchMode::Blocking,+ );+ assert!(envelope.starts_with("[SUBAGENT_INCOMPLETE]"));+ assert!(envelope.contains("do NOT report it as done"));+ assert!(envelope.contains("returned an unexecuted tool call"));+ assert!(envelope.contains("[INLINE_RESULT]"));+}diff --git a/src/openhuman/agent/orchestration/tools/tools_e2e_tests.rs b/src/openhuman/agent/orchestration/tools/tools_e2e_tests.rsindex b3d39014dc..ec3a608ca7 100644--- a/src/openhuman/agent/orchestration/tools/tools_e2e_tests.rs+++ b/src/openhuman/agent/orchestration/tools/tools_e2e_tests.rs@@ -368,7 +368,18 @@ async fn skill_delegation_tool_runs_integrations_agent_e2e() {.expect("tool execution");assert!(!result.is_error, "{}", result.output());- assert_eq!(result.output(), "skill-delegation-child-answer");+ // The sub-agent's answer comes back verbatim, followed by the+ // inline-result note: this delegation is blocking and registers no+ // worker, so the orchestrator must not go hunting for one (#6033).+ let output = result.output();+ assert!(+ output.starts_with("skill-delegation-child-answer"),+ "the child's answer must lead the result: {output}"+ );+ assert!(+ output.contains("[INLINE_RESULT]") && output.contains("no sub-agent worker"),+ "a blocking delegation must say its result is inline: {output}"+ );assert!(provider.saw(SKILL_DELEGATION_CANARY));assert!(provider.saw("gmail"));}