Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zerone0x
Copy link
Contributor

Summary

Fixes #1269

Adds sanitization to extractAssistantText in sessions-helpers.ts to prevent tool call text from leaking to users. Previously, messages retrieved from chat history via sessions-helpers.ts could expose:

  • Minimax XML tool calls (<invoke>...</invoke>)
  • Downgraded tool call markers ([Tool Call: name (ID: ...)])
  • Thinking tags (<think>...</think>)

Changes

  • Export the stripping functions (stripMinimaxToolCallXml, stripDowngradedToolCallText, stripThinkingTagsFromText) from pi-embedded-utils.ts
  • Add a new sanitizeTextContent helper in sessions-helpers.ts that chains the sanitization functions
  • Update extractAssistantText in sessions-helpers.ts to sanitize text content before returning
  • Update extractMessageText in commands-subagents.ts to use the same sanitization

Test plan

  • pnpm lint passes
  • pnpm test src/agents/pi-embedded-utils.test.ts passes (existing tests for the stripping functions)
  • Manual testing: verify tool call markers no longer appear in /subagents log output

🤖 Generated with Claude Code

Adds sanitization to extractAssistantText in sessions-helpers.ts to
prevent tool call text from leaking to users. Previously, messages
retrieved from chat history via sessions-helpers.ts could expose:

- Minimax XML tool calls (<invoke>...</invoke>)
- Downgraded tool call markers ([Tool Call: name (ID: ...)])
- Thinking tags (<think>...</think>)

This fix:
- Exports the stripping functions from pi-embedded-utils.ts
- Adds a new sanitizeTextContent helper in sessions-helpers.ts
- Updates extractAssistantText to sanitize before returning
- Updates extractMessageText in commands-subagents.ts to sanitize

Fixes clawdbot#1269

Co-Authored-By: Claude <[email protected]>
@steipete
Copy link
Contributor

This really needs upstreaming to pi-mono.

@steipete steipete self-assigned this Jan 23, 2026
@steipete steipete merged commit 03bec49 into openclaw:main Jan 23, 2026
20 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: 5516853
  • Merge commit: 03bec49

Thanks @zerone0x!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool call text leaks through unsanitized extractAssistantText in sessions-helpers.ts

2 participants