fix: normalize visible assistant output before delivery#68986
fix: normalize visible assistant output before delivery#68986dutifulbob wants to merge 32 commits into
Conversation
Greptile SummaryThis PR adds Confidence Score: 5/5Safe to merge; the only finding is a pre-existing harmless redundancy now made more visible. The sanitization additions are correct, No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-subscribe.ts
Line: 570-572
Comment:
**Redundant `stripDowngradedToolCallText` call**
`stripDowngradedToolCallText` is already part of the `sanitizeAssistantVisibleText` pipeline (under the `delivery` profile, `preserveDowngradedToolText` is false), so the explicit pre-call here is a no-op. The text passes through `stripDowngradedToolCallText` twice. Consider removing the outer explicit call now that the full sanitizer is in place:
```suggestion
const chunk = sanitizeAssistantVisibleText(
stripBlockTags(text, state.blockState),
);
```
If keeping the explicit call is intentional (e.g., for clarity), a short comment explaining why both are needed would help future readers.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: sanitize visible gemma discord repl..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c067c7fbc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2c067c7 to
12d2cf2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6388970086
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a665e9973
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1641981d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4f32f120e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d5bf4a9d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a999caca29
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbcb606480
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
ClawSweeper PR egg 🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
|
This pull request has been automatically marked as stale due to inactivity. |
Summary
Gemma was sometimes leaking hidden internal text into Discord replies.
This PR makes OpenClaw clean the final reply in one shared place before sending it.
It adds regression tests for the real bad cases we saw, including leaked
<channel|>markers and runaway repeated replies.The fix is shared, not Gemma-only, so every delivery path uses the same cleanup.
What changed
<channel|>control delimiters when they behave like leaked scaffolding<channel|>mentions in ordinary prose<channel|>repeat "ABCD-1234" exactly twice<channel|>literallytext_enddelivery until the final flush so partial raw scaffold chunks are never emitted earlymessage_enddrains as final delivery so the delivery sanitizer runs on the last emitted chunkstext_endreply directives and keep intermediate chunk drains in history mode until final deliveryblockStatewhentext_endreplaces the block buffer with already-sanitized final text, so stale reasoning-tag state cannot strip the final answer on flushRegression tests added first
<channel|>stays intactplan: <channel|>visibleis treated as leaked scaffolding<channel|>stay intact<channel|>literallytext_endreply directives still workmessage_enddrains are marked as final deliverytext_endVerification
pnpm exec vitest run src/shared/text/repeated-visible-suffix.test.ts src/shared/text/assistant-visible-text.test.tspnpm exec vitest run src/shared/text/repeated-visible-suffix.test.ts src/shared/text/assistant-visible-text.test.ts src/agents/pi-embedded-utils.strip-model-special-tokens.test.ts src/agents/pi-embedded-subscribe.handlers.messages.test.ts src/agents/pi-embedded-subscribe.reply-tags.test.ts src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.emits-block-replies-text-end-does-not.test.ts src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.keeps-indented-fenced-blocks-intact.test.ts src/auto-reply/reply/reply-utils.test.tspnpm buildvllm/gemma4-e4bafter restarting the local gateway on this branch:reply with exactly pr68986-live2-1776657698 and nothing elsepr68986-live2-1776657698