Repository navigation
Conversation
…ivery Apply stripInboundMetadata() to outbound payload text during delivery normalization. Previously, AI-facing metadata blocks (Conversation info, Sender info, etc.) injected by buildInboundUserContextPrefix could leak into user-visible messages when the outbound pipeline did not call the strip function. Fixes openclaw#39847 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Co-Authored-By: Codex (GPT-5.4) <[email protected]>
Greptile SummaryThis PR fixes a metadata leakage bug where AI-facing inbound metadata blocks (Conversation info, Sender info, etc.) injected by The fix is a targeted, single-line change in Key points:
Confidence Score: 5/5
Last reviewed commit: "fix(outbound): strip..." |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9750eb8860
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ...payload, | ||
| text: parsed.text ?? "", | ||
| }) ?? "", | ||
| stripInboundMetadata( |
There was a problem hiding this comment.
Preserve legitimate timestamp-prefixed reply text
Calling stripInboundMetadata(...) on every outbound payload can corrupt valid assistant output, because that helper also strips any leading text matching a timestamp pattern (for example "[Wed 2026-03-11 23:51 PDT] ...") in addition to metadata blocks. This function was designed for sanitizing inbound user-role content, so applying it unconditionally here means replies that intentionally begin with bracketed timestamps (logs, schedules, transcripts) will be silently altered before delivery.
Useful? React with 👍 / 👎.
This comment was marked as spam.
This comment was marked as spam.
|
Codex review: found issues before merge. What this changes: The PR imports Maintainer follow-up before merge: This should not go straight to an automated repair lane because the branch is stale/unmergeable, overlaps with #39847/#50520, and current main has a later sanitizer that may supersede part of the original request; maintainer judgment is needed on whether a direct outbound-plan sanitizer remains required. Security review: Security review cleared: The diff changes internal text normalization and tests only; it does not add dependencies, CI permissions, release scripts, secrets handling, downloads, or package execution paths. Review findings:
Review detailsBest possible solution: Keep the assistant/replay sanitizer that already exists on main, then add a narrow outbound-only sanitizer only if maintainers want defense-in-depth at the payload-plan boundary. That sanitizer should remove generated metadata sentinel blocks and terminal untrusted-context suffixes without stripping legitimate timestamp-prefixed reply text, and the remaining work should be consolidated with #39847/#50520. Do we have a high-confidence way to reproduce the issue? Yes. The metadata-leak scenario is represented by the PR test, and the blocking regression is reproducible by passing a timestamp-prefixed payload through the PR branch because Is this the best way to solve the issue? No. Applying the inbound display sanitizer at the shared outbound plan boundary is broader than necessary; a safer fix would be an outbound-specific copied-metadata sanitizer that preserves ordinary assistant content such as logs and transcripts. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 36eec68fb9cd. |
|
Superseded by #50520 which includes the strip-inbound-meta.ts fix as well. Closing in favor of the comprehensive PR. |
Summary
stripInboundMetadata()to outbound payload text innormalizeReplyPayloadsForDelivery(), preventing AI-facing metadata blocks from leaking into user-visible messagesbuildInboundUserContextPrefixwas not being stripped in the outbound delivery pipelineFixes #39847
Related: #41355
Details
normalizeReplyPayloadsForDelivery()processes reply payloads throughformatBtwTextForExternalDeliverybut did not callstripInboundMetadata(). This meant that on delivery paths where the text still contained raw inbound metadata blocks, those blocks would appear in the user-facing message.The fix wraps the existing
formatBtwTextForExternalDelivery(...)result withstripInboundMetadata(...)— a single-line change at the source level that covers all delivery paths (Discord, compact mode, Pi-embedded, etc.) without needing per-adapter patches.Test plan
pnpm test -- src/infra/outbound/payloads.test.ts— new test verifies metadata stripping🤖 Generated with Claude Code + Codex