Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(harness): accept doubled tool_call tags as one call

Steven Enamakel6d5a6a2b3df7
diff --git a/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs b/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs
index 88ce3c9f73..78041eb55c 100644
--- a/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs
@@ -1,17 +1,18 @@
use super::*;
#[test]
-fn parse_tool_calls_nested_xml_tags_are_rejected() {
- // A nested tool_call span is malformed protocol output. The strict parser
- // must leave it unexecuted rather than guessing which tag owns the JSON.
+fn parse_tool_calls_doubled_xml_tags_are_one_call() {
+ // A doubled tag with nothing between the two openers is not ambiguous:
+ // there is exactly one body and one call. DeepSeek V4 emits this shape
+ // under a text dialect, and rejecting it leaked the whole block into the
+ // visible reply (tinyhumansai/tinytools#20).
let response =
r#"<tool_call><tool_call>{"name":"echo","arguments":{"msg":"hi"}}</tool_call></tool_call>"#;
- let (_text, calls) = parse_tool_calls(response);
- // Nested markup must not become an executable call.
- assert!(
- calls.is_empty(),
- "nested XML tags must not yield an ambiguous executable tool call"
- );
+ let (text, calls) = parse_tool_calls(response);
+ assert_eq!(calls.len(), 1, "{calls:?}");
+ assert_eq!(calls[0].name, "echo");
+ assert_eq!(calls[0].arguments["msg"], "hi");
+ assert!(!text.contains("tool_call"), "no tag may survive into the text: {text:?}");
}
#[test]