fix(agent): strip prompt-guided tool artifacts from visible replies#3200
Merged
theonlyhennygod merged 1 commit intozeroclaw-labs:masterfrom Mar 11, 2026
Merged
Conversation
lantrinh1999
pushed a commit
to lantrinh1999/zeroclaw-1
that referenced
this pull request
Mar 18, 2026
…l-result-display fix(agent): strip prompt-guided tool artifacts from visible replies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
masterfor all contributions):master<tool_result>and<thinking>blocks back into the assistant text shown to users.display_textonly and add regression tests for the cleanup cases.Label Snapshot (required)
risk: low|medium|high):risk: mediumsize: XS|S|M|L|XL, auto-managed/read-only):size: Score|agent|channel|config|cron|daemon|doctor|gateway|health|heartbeat|integration|memory|observability|onboard|provider|runtime|security|service|skillforge|skills|tool|tunnel|docs|dependencies|ci|tests|scripts|dev, comma-separated):agent,tests<module>: <component>, for examplechannel: telegram,provider: kimi,tool: shell):agent: looptrusted contributor|experienced contributor|principal contributor|distinguished contributor, auto-managed/read-only; author merged PRs >=5/10/20/50):auto-managedN/AChange Metadata
bug|feature|refactor|docs|security|chore):bugruntime|provider|channel|memory|security|ci|docs|multi):runtimeLinked Issue
N/AN/AN/AN/ASupersede Attribution (required when
Supersedes #is used)#<pr> by @<author>, one per line):N/AN/ACo-authored-bytrailers added for materially incorporated contributors? (Yes/No):NoNo, explain why (for example: inspiration-only, no direct code/design carry-over):Direct code was reimplemented on current master layout without copying prior branch commits.\n): (Pass/Fail):PassValidation Evidence (required)
Commands and result summary:
cargo fmt --all -- --check cargo clippy --all-targets -- -D warnings cargo testAdded 6 regression tests for visible reply cleanup; all commands passed locally.NoneSecurity Impact (required)
Yes/No):NoYes/No):NoYes/No):NoYes/No):NoYes, describe risk and mitigation:N/APrivacy and Data Hygiene (required)
pass|needs-follow-up):passNo new user data persisted; visible output cleanup only.ConfirmedCompatibility / Migration
Yes/No):YesYes/No):NoYes/No):NoN/Ai18n Follow-Through (required when docs or user-facing wording changes)
Yes/No):NoYes, locale navigation parity updated inREADME*,docs/README*, anddocs/SUMMARY.mdfor supported locales (en,zh-CN,ja,ru,fr,vi)? (Yes/No):N/AYes, localized runtime-contract docs updated where equivalents exist (minimum forfr/vi:commands-reference,config-reference,troubleshooting)? (Yes/No/N.A.):N/AYes, Vietnamese canonical docs underdocs/i18n/vi/**synced and compatibility shims underdocs/*.vi.mdvalidated? (Yes/No/N.A.):N/ANo/N.A., link follow-up issue/PR and explain scope decision:No docs or user-facing copy contract changed.Human Verification (required)
What was personally validated beyond CI:
Visible reply text now strips echoed <tool_result> blocks, [Tool results] prefixes, and <thinking> blocks while preserving clean text.Single block, multiple blocks, only-tag payloads, prefix-only cases, and clean replies.Manual live-channel reproduction against an external provider was not performed.Side Effects / Blast Radius (required)
Agent visible reply rendering across channel and CLI paths that consume display_text.Literal user-visible strings matching these internal tags will be hidden from final display.Raw response history remains unchanged, and new regression tests cover the stripping rules.Agent Collaboration Notes (recommended)
Codex terminal tools, git, ghReimplemented the fix on latest master layout, added regression tests, and validated with repo-standard commands.Visible-output cleanup without altering stored raw history.AGENTS.md+CONTRIBUTING.md):ConfirmedRollback Plan (required)
git revert 1c2a4945NoneUsers would again see echoed tool-result/thinking artifacts in replies.Risks and Mitigations
<thinking>or<tool_result>content in a final reply could be removed from visible output.display_text; raw response history is preserved, and tests document the intended stripping behavior.