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
refactor(tools): use shared tool-call text helpers from tinytools-agent
Steven Enamakela83d93055d29
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rsindex fd8fba6d3f..cd9fd71d3a 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs@@ -13,7 +13,6 @@ use tinytools::ToolRunContext;use tinytools::{ToolCallOptions, ToolResult};mod dispatch_outcomes;-mod tool_call_text;pub(crate) use dispatch_outcomes::*;/// Typed dispatch for the delegation tools synthesised from the active agent.diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rsindex a4d43d633f..a27e77e95e 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs@@ -32,7 +32,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 super::tool_call_text::{contains_tool_call_payload, strip_tool_calls_from_response};+ use tinytools_agent::dialect::{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.rsdeleted file mode 100644index 39b2fcd24c..0000000000--- a/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text.rs+++ /dev/null@@ -1,96 +0,0 @@-//! 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.rsdeleted file mode 100644index 1ad73428eb..0000000000--- a/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs+++ /dev/null@@ -1,40 +0,0 @@-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>"),- ""- );-}