Skip to content

[Bug]: Bug: Sanitization — Tool Call Tags Escape to Final Response #40020

@TiagoAndrade84

Description

@TiagoAndrade84

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

  1. Execute multiple tool calls in a single message (e.g., exec + edit + write)
  2. Receive response with tool results
  3. 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

  1. User completes a successful woo-seo optimization (multiple tool calls)
  2. OpenClaw asks "Want to optimize another product?"
  3. User takes 9 minutes to respond "Yes" via Telegram
  4. User's Telegram messages don't reach OpenClaw (confirmed in Dashboard)
  5. User switches to Dashboard and sends the same request
  6. OpenClaw responds with garbled text (corrupted output with escaped tags)
  7. After timeout/recovery, OpenClaw responds again with "tool_use ids must be unique" error

Expected behavior

Expected Behavior

  1. User completes woo-seo optimization
  2. OpenClaw asks follow-up question
  3. User responds after delay (9 minutes) via Telegram
  4. Response is delivered successfully to OpenClaw
  5. OpenClaw processes the request normally
  6. Response is delivered to user without internal tags (<|tool_call_result_begin|>, <|tool_list_end|>, etc.)
  7. Message is readable and properly formatted in Telegram
  8. 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 step

Impact 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

  1. User Experience

    • Messages become unreadable in Telegram
    • Impossible to select/copy text (iOS)
    • Confusing error messages
    • Loss of trust in system reliability
  2. 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
  3. Production Use

    • Can't reliably run complex operations via Telegram
    • Dashboard becomes mandatory for serious tasks
    • State corruption after operations (subsequent tool calls fail)
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions