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(orchestration): remove unused dispatch outcomes module
Steven Enamakel41fa87b1fea7
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rsindex e97a39ff7b..6b8d25eba2 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs@@ -30,9 +30,7 @@ pub(super) fn format_subagent_failure(tool_name: &str, message: &str) -> String}pub(crate) fn is_unexecuted_tool_call_stub(output: &str) -> bool {- use crate::agent::harness::archivist::helpers::{- contains_tool_call_payload, strip_tool_calls_from_response,- };+ use super::tool_call_text::{contains_tool_call_payload, strip_tool_calls_from_response};if !contains_tool_call_payload(output) {return false;}diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text.rs b/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text.rsnew file mode 100644index 0000000000..39b2fcd24c--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text.rs@@ -0,0 +1,96 @@+//! Recognising tool-call markup a sub-agent wrote as text instead of+//! executing (#6033), and stripping it to see whether any prose remains.++/// Whether `text` carries tool-call markup rather than (only) prose.+///+/// This is the single place the marker vocabulary is written down. 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 {+ contains_tool_call_payload(text) || text.contains("\"tool_use\"")+}++/// Whether `text` carries a **call-shaped** payload — an XML tool-call span+/// or a `tool_calls` JSON key.+///+/// Narrower than [`looks_like_unexecuted_tool_call`] on purpose: `"tool_use"`+/// alone appears in ordinary prose about the protocol, which is fine for+/// deciding whether stripping is worth attempting but not for deciding that+/// a sub-agent produced no answer.+///+/// The JSON key is matched without assuming it opens the object, so a+/// pretty-printed `{\n "tool_calls": [...]\n}` is recognised too.+pub(crate) fn contains_tool_call_payload(text: &str) -> bool {+ text.contains("<tool_call>") || text.contains("\"tool_calls\"")+}++/// Strip tool-call JSON blocks from an assistant response, leaving only the+/// prose text.+///+/// This function applies a lightweight heuristic: it removes any contiguous+/// spans of text that look like `<tool_call>…</tool_call>` XML/JSON blocks or+/// 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(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 !looks_like_unexecuted_tool_call(response) {+ return response.to_string();+ }++ // Remove XML-style tool-call blocks.+ let mut cleaned = response.to_string();++ // Strip <tool_call>…</tool_call> spans (may span multiple lines).+ while let Some(start) = cleaned.find("<tool_call>") {+ if let Some(end) = cleaned[start..].find("</tool_call>") {+ cleaned.drain(start..start + end + "</tool_call>".len());+ } else {+ // Unclosed tag — remove from the tag to end of string.+ cleaned.truncate(start);+ break;+ }+ }++ // Drop JSON / tool-use payload lines the XML strip above cannot catch.+ cleaned = cleaned+ .lines()+ .filter(|line| {+ let l = line.trim();+ !(l.contains("\"tool_use\"")+ || l.starts_with("{\"tool_calls\"")+ || l.starts_with("\"tool_calls\""))+ })+ .collect::<Vec<_>>()+ .join("\n");++ // Trim and collapse runs of blank lines left by block removal.+ let trimmed = cleaned+ .lines()+ .map(str::trim_end)+ .collect::<Vec<_>>()+ .join("\n");++ // Collapse more than two consecutive newlines to two.+ let mut result = String::with_capacity(trimmed.len());+ let mut blank_run = 0usize;+ for line in trimmed.lines() {+ if line.is_empty() {+ blank_run += 1;+ if blank_run <= 2 {+ result.push('\n');+ }+ } else {+ blank_run = 0;+ result.push_str(line);+ result.push('\n');+ }+ }++ result.trim().to_string()+}++#[cfg(test)]+#[path = "tool_call_text_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rsnew file mode 100644index 0000000000..7f27f095c7--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs@@ -0,0 +1,32 @@+use super::*;++#[test]+fn prose_is_not_a_tool_call() {+ assert!(!looks_like_unexecuted_tool_call("All done, the file is saved."));+ assert!(!contains_tool_call_payload("All done."));+ assert_eq!(strip_tool_calls_from_response(" plain "), " plain ");+}++#[test]+fn xml_and_json_payloads_are_recognised() {+ assert!(contains_tool_call_payload("<tool_call>{}</tool_call>"));+ assert!(contains_tool_call_payload("{\n \"tool_calls\": []\n}"));+ assert!(looks_like_unexecuted_tool_call("{\"tool_use\": 1}"));+ assert!(!contains_tool_call_payload("{\"tool_use\": 1}"));+}++#[test]+fn stripping_keeps_only_the_prose() {+ let text = "Before\n<tool_call>{\"name\":\"x\"}</tool_call>\n\n\n\nAfter\n{\"tool_calls\": []}";+ assert_eq!(strip_tool_calls_from_response(text), "Before\n\n\nAfter");+}++#[test]+fn an_unclosed_tag_drops_the_tail() {+ assert_eq!(strip_tool_calls_from_response("Keep <tool_call>{\"a\":1"), "Keep");+}++#[test]+fn a_pure_payload_strips_to_empty() {+ assert_eq!(strip_tool_calls_from_response("<tool_call>{}</tool_call>"), "");+}