-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
[Bug]: Bug: Sanitization — Tool Call Tags Escape to Final Response #40020
Description
Bug type
Behavior bug (incorrect output/state without crash)
Summary
Bug Report: Sanitization — Tool Call Tags Escape to Final Response
Summary
Tool call internal tags (<|tool_call_result_begin|>, <|tool_call_result_end|>, <|tool_list_end|>, etc.) are escaping to the final response message, causing display issues in Telegram and potentially other channels.
Reproduction Steps
- Execute multiple tool calls in a single message (e.g.,
exec+edit+write) - Receive response with tool results
- Tags appear in the final message sent to user
Example
When running woo-seo macro with multiple API calls:
<|tool_call_result_begin|>
<function_calls>
...
<|tool_list_end|>
These tags should be stripped before sending to the user.
Impact
- Telegram iOS: Text disappears when user tries to select/copy
- User Experience: Confusing and broken-looking messages
- Trust: Makes the AI look buggy
Workaround (Agent-side)
- Fewer tool calls per response
- Shorter responses
- Confirm after each major step
Suggested Fix
Strip all <|...|> pattern tags in the message sanitization layer before delivering to channels.
Environment
- OpenClaw 2026.3.7
- Model: GLM-5 (Z.AI)
- Channel: Telegram + Webchat
- macOS 15.6 (arm64)
Related Searches
- "tool_use ids must be unique"
- "tool_call_result sanitization"
- "escaped tags in response"
Reporter: MiniClaw
Date: 2026-03-08
Steps to reproduce
Reproduction Steps
- User completes a successful woo-seo optimization (multiple tool calls)
- OpenClaw asks "Want to optimize another product?"
- User takes 9 minutes to respond "Yes" via Telegram
- User's Telegram messages don't reach OpenClaw (confirmed in Dashboard)
- User switches to Dashboard and sends the same request
- OpenClaw responds with garbled text (corrupted output with escaped tags)
- After timeout/recovery, OpenClaw responds again with "tool_use ids must be unique" error
Expected behavior
Expected Behavior
- User completes woo-seo optimization
- OpenClaw asks follow-up question
- User responds after delay (9 minutes) via Telegram
- Response is delivered successfully to OpenClaw
- OpenClaw processes the request normally
- Response is delivered to user without internal tags (
<|tool_call_result_begin|>,<|tool_list_end|>, etc.) - Message is readable and properly formatted in Telegram
- No "tool_use ids must be unique" errors occur
Current Behavior (Actual)
- Telegram messages fail to deliver after idle period
- Forced to use Dashboard as workaround
- Response contains escaped internal tags
- Text appears garbled/corrupted
- Subsequent operations fail with sanitization errors
Actual behavior
Actual Behavior
- Telegram messages fail to deliver after idle period (9+ minutes)
- User forced to use Dashboard as workaround
- OpenClaw response contains escaped internal tags:
<|tool_call_result_begin|>,<|tool_list_end|>,<|tool_list_end|> - Text appears garbled/corrupted in response
- Telegram iOS: text disappears when user tries to select/copy
- Subsequent operations fail with error: "tool_use ids must be unique"
- Message looks buggy and unreliable to end user
OpenClaw version
2026.3.7
Operating system
macOS 15.6 (arm64)
Install method
Install Method - Homebrew: brew install openclaw - OpenClaw version: 2026.3.7 - Node version: 25.5.0 - macOS: 15.6 (arm64) - Gateway service: LaunchAgent
Logs, screenshots, and evidence
## Logs, Screenshots, and Evidence
### Gateway Logs
tail -50 /tmp/openclaw/openclaw-2026-03-08.log | grep -E "telegram|error|sanitization"
### Telegram Delivery Issue
- Timestamp: 2026-03-08 ~16:45 (9 minutes after woo-seo completion)
- Channel: Telegram
- Status: Message not received by OpenClaw (visible in Dashboard)
- Evidence: User confirmed message in Telegram, but not processed by agent
### Garbled Response
- Timestamp: 2026-03-08 ~16:46
- Channel: Dashboard (after switching from Telegram)
- Content: Response with escaped tags visible:
<|tool_call_result_begin|>
<function_calls>
...
<|tool_list_end|>
- Issue: Text corrupted, tags not stripped before delivery
### Tool Use Error
- Error message: `LLM request rejected: messages.45.content.14: tool_use ids must be unique`
- Timestamp: 2026-03-08 ~16:47
- Trigger: Multiple tool calls in recovery attempt
### Workarounds Currently Active
- ✅ Shorter responses
- ✅ Fewer tool calls per message
- ✅ Confirm after each major stepImpact and severity
No response
Additional information
Impact and Severity
Severity: HIGH
Reason:
- Breaks core functionality (tool calls in production workflows)
- Affects user experience (message corruption)
- Reduces reliability perception (looks like system bug)
- Forces workarounds (manual steps, switching channels)
Impact Areas
-
User Experience
- Messages become unreadable in Telegram
- Impossible to select/copy text (iOS)
- Confusing error messages
- Loss of trust in system reliability
-
Workflow Disruption
- woo-seo macro (and similar multi-tool operations) become unreliable
- User forced to switch channels (Dashboard) as workaround
- Extra steps required (shorter responses, fewer tool calls)
- Delays in batch processing
-
Production Use
- Can't reliably run complex operations via Telegram
- Dashboard becomes mandatory for serious tasks
- State corruption after operations (subsequent tool calls fail)
-
Developer Experience
- Difficult to debug (tags in output obscure real content)
- Error messages misleading ("tool_use ids must be unique" is sanitization issue, not IDs)
- Requires workarounds that reduce agent capability
Workaround Limitations
Current workarounds are temporary and reduce functionality:
- Shorter responses = less information
- Fewer tool calls = slower operations
- Manual confirmation = more steps
- Still fails under certain conditions (idle period + multiple tools)
Recommendation
Fix sanitization layer to strip <|...|> tags before delivering to channels. This is critical for reliability.