fix(#24): strip all XML pseudo tool-call dialects from model replies #68

Merged
salmaelsoly merged 5 commits from development_strip_xml_tool_call_text into development 2026-06-02 10:07:03 +00:00
Member

Summary

Completes the fix for issue #24 — pseudo tool-call text leaking to the user.

PR #52 fixed the [TOOL_CALL]{tool => …}[/TOOL_CALL] bracket dialect. Retesting revealed three additional XML formats that were not handled. This PR adds three-layer defense (engine → server → UI) for all of them.

Formats added

Format Dialect
<tool_call><function_name>…</function_name></tool_call> DeepSeek / Hermes
<function_calls><invoke name="…">…</invoke></function_calls> Anthropic/Claude XML
<execute><cmd>…</cmd></execute> misc models

Changes per layer

  • store.tsstripBracketToolCalls() extended with all three new regex patterns (applied at streaming flush + turn:end, no call-site changes needed)
  • session.rs strip_fake_tool_call_envelopes — one strip step added per format, each with tracing::warn! + tests
  • tool_call_recovery.rsstrip_xml_tool_calls + parse_xml_tool_call_body, strip_function_calls_xml + parse_function_calls_body, strip_execute_xml + parse_execute_body
  • tool_call_recovery_module.rs — all three hooked into lift_recovered_tool_calls: promote to real tool call when name is in tool map, suppress otherwise

Closes #24

## Summary Completes the fix for issue #24 — pseudo tool-call text leaking to the user. PR #52 fixed the `[TOOL_CALL]{tool => …}[/TOOL_CALL]` bracket dialect. Retesting revealed three additional XML formats that were not handled. This PR adds three-layer defense (engine → server → UI) for all of them. ### Formats added | Format | Dialect | |--------|---------| | `<tool_call><function_name>…</function_name></tool_call>` | DeepSeek / Hermes | | `<function_calls><invoke name="…">…</invoke></function_calls>` | Anthropic/Claude XML | | `<execute><cmd>…</cmd></execute>` | misc models | ### Changes per layer - **`store.ts`** — `stripBracketToolCalls()` extended with all three new regex patterns (applied at streaming flush + `turn:end`, no call-site changes needed) - **`session.rs` `strip_fake_tool_call_envelopes`** — one strip step added per format, each with `tracing::warn!` + tests - **`tool_call_recovery.rs`** — `strip_xml_tool_calls` + `parse_xml_tool_call_body`, `strip_function_calls_xml` + `parse_function_calls_body`, `strip_execute_xml` + `parse_execute_body` - **`tool_call_recovery_module.rs`** — all three hooked into `lift_recovered_tool_calls`: promote to real tool call when name is in tool map, suppress otherwise Closes #24
salmaelsoly force-pushed development_strip_xml_tool_call_text from c655393909
Some checks failed
Verify / verify (push) Failing after 11s
Verify / verify (pull_request) Failing after 11s
to c379a71454
Some checks failed
Verify / verify (push) Failing after 12s
Verify / verify (pull_request) Failing after 14s
2026-06-02 08:03:05 +00:00
Compare
style: cargo fmt
All checks were successful
Verify / verify (push) Successful in 13m53s
Verify / verify (pull_request) Successful in 14m2s
0ea5053fd9
salmaelsoly merged commit 6b11c10e26 into development 2026-06-02 10:07:03 +00:00
salmaelsoly deleted branch development_strip_xml_tool_call_text 2026-06-02 10:07:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_shrimp!68
No description provided.