fix(gateway): strip internal tool-trace banners from chat output - #54959
Open
ooiuuii wants to merge 1 commit into
Open
fix(gateway): strip internal tool-trace banners from chat output#54959ooiuuii wants to merge 1 commit into
ooiuuii wants to merge 1 commit into
Conversation
ooiuuii
force-pushed
the
fix/chat-tool-trace-sanitize
branch
from
June 29, 2026 18:20
b88fb9e to
29b079c
Compare
13 tasks
ooiuuii
force-pushed
the
fix/chat-tool-trace-sanitize
branch
from
July 6, 2026 01:53
29b079c to
7c20481
Compare
teknium1
reviewed
Jul 15, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for covering both final and streamed output paths. The premise is still present on current main: gateway/run.py:434 only redacts secrets before returning final chat text, and gateway/stream_consumer.py:1647 reaches BasePlatformAdapter.strip_media_directives_for_display(), whose current implementation at gateway/platforms/base.py:3710-3718 only handles media directives.
Problems
gateway/run.py:445adds banner stripping to_prepare_gateway_status_message(), but the PR adds no direct test for that status-delivery path.tests/gateway/test_telegram_noise_filter.pycovers final responses;tests/gateway/test_stream_consumer.pycovers streamed display.
Suggested changes
- Add a status-helper regression test for a chat platform and a raw platform, using the same banner fixture and raw-surface contract as the final-response tests.
Automated hermes-sweeper review.
| @@ -443,7 +445,7 @@ def _prepare_gateway_status_message(platform: Any, event_type: str, message: str | |||
| if _gateway_surface_passes_raw_text(platform): | |||
Contributor
There was a problem hiding this comment.
This adds a third sanitization boundary, but the new tests cover only final responses and streamed display. Please add a direct _prepare_gateway_status_message() regression test for both a chat surface and a raw surface.
ooiuuii
force-pushed
the
fix/chat-tool-trace-sanitize
branch
from
August 13, 2026 08:12
7c20481 to
f07e002
Compare
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
GatewayStreamConsumer._clean_for_display()so streamed chat text gets the same backstopContext
This ports the same outbound boundary covered by OpenClaw's recent Slack/Matrix fixes:
Fixes #54957.
Duplicate Audit
Related but not a duplicate of #38732: that PR blocks stale commentary after final delivery and fixes a Telegram duplicate-send path. This PR is a narrower outbound sanitizer for already-assembled chat text that contains internal tool-trace banner lines, and it applies to final responses, status messages, and streaming display cleanup across chat surfaces while preserving raw local/API/webhook diagnostics.
Also adjacent to #30574, #53334, and #54865, but those cover compression/status/error/runtime notices. This PR only strips the internal tool-trace banner shape shown above.
Tests
TMP=.tmp-pytest TEMP=.tmp-pytest TMPDIR=.tmp-pytest .\.venv\Scripts\python.exe -m pytest tests/gateway/test_telegram_noise_filter.py tests/gateway/test_stream_consumer.py -q(325 passed)TMP=.tmp-pytest TEMP=.tmp-pytest TMPDIR=.tmp-pytest .\.venv\Scripts\python.exe -m ruff check gateway/platforms/base.py gateway/run.py gateway/stream_consumer.py tests/gateway/test_telegram_noise_filter.py tests/gateway/test_stream_consumer.pygit diff --check