Skip to content

fix(outbound): strip inbound metadata before delivery - #50520

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
p3nchan:fix/strip-inbound-metadata-outbound-delivery
Jul 31, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
p3nchan:fix/strip-inbound-metadata-outbound-delivery

Conversation

@p3nchan

@p3nchan p3nchan commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #39847

What Problem This Solves

Fixes an issue where users could receive OpenClaw-injected inbound context, such as location or plugin metadata, when a model echoed those blocks at the start of its reply.

Why This Change Was Made

The shared outbound payload planner now removes only leading marker-backed inbound metadata before parsing reply directives. It reuses the current stripLeadingInboundMetadata() contract, so newer message-tool and chat-window protections remain untouched and marked examples after visible reply text are preserved.

User Impact

Telegram, Discord, and other channel users receive the intended reply without internal inbound context leaking into the delivered message.

Evidence

  • Rebased-head mock-gateway proof for 5b8854e7896ebbd84b98c55c7a4138e4adbd6f50: Blacksmith Testbox tbx_01kyvz3a1hftmy3f9adem2dxc3, https://github.com/openclaw/openclaw/actions/runs/30627335452
  • Testbox hydrated the commit's exact parent 0d40cfbb538dd10bcdbd42fb2e0f51cba7c0bf76 and synchronized the rebased commit tree plus the temporary QA scenario. The proof ran mock-openai through an ephemeral Gateway and qa-channel; the delivered channel text was exactly Visible reply delivered unchanged. with both leading marker-backed metadata blocks absent.
  • Mantis Telegram Desktop run https://github.com/openclaw/openclaw/actions/runs/30617951309 was attempted twice on the earlier exact head. Both attempts failed in baseline/test-chat setup before candidate execution, so they do not indicate a candidate regression.
  • node scripts/run-vitest.mjs src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts - 94 tests passed.
  • node scripts/run-vitest.mjs src/gateway/chat-sanitize.test.ts src/tui/tui-formatters.test.ts - 78 tests passed.
  • Targeted type-aware oxlint passed for both changed files.
  • Targeted formatting and git diff --check passed.
  • Autoreview reported no accepted or actionable findings.

Rebased-head gateway verdict

{
  "headSha": "5b8854e7896ebbd84b98c55c7a4138e4adbd6f50",
  "baseSha": "0d40cfbb538dd10bcdbd42fb2e0f51cba7c0bf76",
  "provider": "mock-openai",
  "gateway": "ephemeral",
  "channel": "qa-channel",
  "scenario": "outbound-leading-inbound-metadata-strip",
  "input": "leading marker-backed Location and Plugin context blocks followed by a visible reply",
  "observedDelivery": "Visible reply delivered unchanged.",
  "counts": {
    "passed": 1,
    "failed": 0,
    "skipped": 0
  },
  "result": "pass",
  "testbox": "tbx_01kyvz3a1hftmy3f9adem2dxc3",
  "runUrl": "https://github.com/openclaw/openclaw/actions/runs/30627335452"
}

AI-assisted: the original contributor test case was co-authored with Claude (Anthropic); the maintainer rebase repair used Codex.

@greptile-apps

greptile-apps Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes issue #39847 by calling stripInboundMetadata() on LLM response text inside normalizeReplyPayloadsForDelivery before the reply-directive parser runs. This prevents OpenClaw-injected metadata blocks echoed verbatim by the LLM (e.g. Conversation info (untrusted metadata): + JSON fence) from leaking to end-users on Discord, Telegram, etc.

  • src/infra/outbound/payloads.ts — minimal, correct change: clean the text first, then parse directives. The cleaned text (parsed.text) correctly flows through formatBtwTextForExternalDelivery to become the final outbound text.
  • src/infra/outbound/payloads.test.ts — well-targeted integration test that exercises the specific echo scenario from the bug report.
  • Minor observation: stripInboundMetadata has a secondary side-effect of always stripping a leading OpenClaw-format timestamp prefix ([Mon 2024-03-15 08:30] …) even when no inbound metadata sentinels are found. This is pre-existing behaviour in the function (already relied on by the TUI and cost calculations), but applying it to outbound delivery text is new. The timestamp pattern is highly specific to OpenClaw's injected format so real LLM output collisions are extremely unlikely, but it is worth noting as an undocumented side-effect of this call site.

Confidence Score: 4/5

  • Safe to merge — the fix is minimal, well-tested, and addresses a real leakage bug with no meaningful risk of regression.
  • The change is two lines in the implementation plus one targeted test. The stripInboundMetadata function is already battle-tested in other call sites. The only deduction is for the implicit timestamp-stripping side-effect on ALL outbound text (even without metadata), which is undocumented at this call site. The practical impact is negligible given how specific the timestamp regex is.
  • No files require special attention beyond the style note on the timestamp side-effect in src/infra/outbound/payloads.ts.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/infra/outbound/payloads.ts
Line: 62-63

Comment:
**`stripInboundMetadata` always strips timestamp prefix, not just when sentinels are present**

`stripInboundMetadata` unconditionally applies `LEADING_TIMESTAMP_PREFIX_RE` before checking for sentinels and returns `withoutTimestamp` even on the fast path (when no sentinel is found):

```ts
const withoutTimestamp = text.replace(LEADING_TIMESTAMP_PREFIX_RE, "");
if (!SENTINEL_FAST_RE.test(withoutTimestamp)) {
  return withoutTimestamp; // timestamp already stripped
}
```

Before this PR, `parseReplyDirectives` received the raw `payload.text`. After it, any LLM response whose first characters happen to match `[Mon 2024-03-15 08:30] ` will have that prefix silently removed from delivery. Since the pattern is quite specific to OpenClaw's injected format this is very unlikely to affect real LLM output, but it is a subtle behavioural change beyond the stated goal of stripping inbound metadata blocks. Worth being aware of, and potentially worth a dedicated `cleanText` test for the timestamp-only path.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "fix(outbound): strip..."

Comment thread src/infra/outbound/payloads.ts Outdated
Comment on lines +62 to +63
const cleanText = stripInboundMetadata(payload.text ?? "");
const parsed = parseReplyDirectives(cleanText);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 stripInboundMetadata always strips timestamp prefix, not just when sentinels are present

stripInboundMetadata unconditionally applies LEADING_TIMESTAMP_PREFIX_RE before checking for sentinels and returns withoutTimestamp even on the fast path (when no sentinel is found):

const withoutTimestamp = text.replace(LEADING_TIMESTAMP_PREFIX_RE, "");
if (!SENTINEL_FAST_RE.test(withoutTimestamp)) {
  return withoutTimestamp; // timestamp already stripped
}

Before this PR, parseReplyDirectives received the raw payload.text. After it, any LLM response whose first characters happen to match [Mon 2024-03-15 08:30] will have that prefix silently removed from delivery. Since the pattern is quite specific to OpenClaw's injected format this is very unlikely to affect real LLM output, but it is a subtle behavioural change beyond the stated goal of stripping inbound metadata blocks. Worth being aware of, and potentially worth a dedicated cleanText test for the timestamp-only path.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/outbound/payloads.ts
Line: 62-63

Comment:
**`stripInboundMetadata` always strips timestamp prefix, not just when sentinels are present**

`stripInboundMetadata` unconditionally applies `LEADING_TIMESTAMP_PREFIX_RE` before checking for sentinels and returns `withoutTimestamp` even on the fast path (when no sentinel is found):

```ts
const withoutTimestamp = text.replace(LEADING_TIMESTAMP_PREFIX_RE, "");
if (!SENTINEL_FAST_RE.test(withoutTimestamp)) {
  return withoutTimestamp; // timestamp already stripped
}
```

Before this PR, `parseReplyDirectives` received the raw `payload.text`. After it, any LLM response whose first characters happen to match `[Mon 2024-03-15 08:30] ` will have that prefix silently removed from delivery. Since the pattern is quite specific to OpenClaw's injected format this is very unlikely to affect real LLM output, but it is a subtle behavioural change beyond the stated goal of stripping inbound metadata blocks. Worth being aware of, and potentially worth a dedicated `cleanText` test for the timestamp-only path.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the timestamp prefix behavior. A few points:

  1. The [Day YYYY-MM-DD HH:MM] timestamp prefix is injected by OpenClaw's own injectTimestamp (in inbound-meta.ts) — it's not user-authored content. An LLM response beginning with that exact format would be extremely unlikely.

  2. stripInboundMetadata already runs on TUI display and session cost paths with the same unconditional timestamp strip, so this PR is consistent with existing usage.

  3. The regex is narrow (/^\[Day YYYY-MM-DD HH:MM...\] */) — it only matches the specific OpenClaw envelope format at the start of the string, not arbitrary bracketed text.

That said, if maintainers prefer a more surgical approach (e.g., only strip the timestamp when a sentinel is also present), I'm happy to adjust.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad14976ebe

ℹ️ 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".

Comment thread src/infra/outbound/payloads.ts Outdated
continue;
}
const parsed = parseReplyDirectives(payload.text ?? "");
const cleanText = stripInboundMetadata(payload.text ?? "");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict metadata stripping to avoid deleting real timestamp text

Applying stripInboundMetadata to every outbound payload now removes leading bracketed timestamps even when no injected metadata block is present, so assistant replies that intentionally begin with log/timestamp text (for example, [Thu 2026-03-12 07:00 UTC] ...) are silently altered before delivery. This regression comes from sanitizing all outgoing text with a helper that also strips timestamp prefixes; using a leading-block-only sanitizer or gating on actual metadata sentinels would avoid dropping legitimate content.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern as above — addressed in my reply to the Greptile comment. The timestamp regex is OpenClaw's own envelope format injected by injectTimestamp, and this function is already used on TUI/session-cost paths with the same behavior. Happy to adjust if maintainers want a tighter guard.

@p3nchan

p3nchan commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review feedback from both @greptile-apps and @chatgpt-codex-connector.

Re: LEADING_TIMESTAMP_PREFIX_RE unconditionally stripping timestamps

Valid concern. The current implementation applies the timestamp regex before checking for sentinels, which means a reply that legitimately starts with [Thu 2026-03-12 07:00 UTC] would have that prefix stripped even if no metadata was injected.

The fix is straightforward — only apply the timestamp strip when a metadata sentinel is actually detected:

// Before (current)
const withoutTimestamp = text.replace(LEADING_TIMESTAMP_PREFIX_RE, "");
if (!SENTINEL_FAST_RE.test(withoutTimestamp)) return withoutTimestamp;

// After (proposed)
if (!SENTINEL_FAST_RE.test(text)) return text;
const withoutTimestamp = text.replace(LEADING_TIMESTAMP_PREFIX_RE, "");

This way, the timestamp prefix is only stripped as part of the metadata cleanup path, not on clean text. Will push a fix commit.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

To use Codex here, create an environment for this repo.

@greptile-apps

greptile-apps Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Perfect solution! Moving the sentinel check before the timestamp strip is exactly right — it ensures legitimate timestamps are preserved when no metadata is present, and the timestamp removal only happens as part of the actual metadata cleanup path.

The early return when no sentinel is detected also makes the fast path cleaner.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27b4344d32

ℹ️ 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".

Comment thread src/infra/outbound/payloads.ts Outdated
continue;
}
const parsed = parseReplyDirectives(payload.text ?? "");
const cleanText = stripInboundMetadata(payload.text ?? "");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit outbound metadata stripping to leading echoed blocks

normalizeReplyPayloadsForDelivery now applies stripInboundMetadata to every assistant payload, but that helper removes any matching metadata block anywhere in the text, not just echoed prefixes. This causes legitimate responses to be altered when the model is asked to show those sentinel headers/JSON blocks verbatim (for example in docs or debugging output), because the block is silently deleted before delivery. In this path, using a leading-only sanitizer (the existing stripLeadingInboundMetadata) would still fix echoed prompt prefixes without corrupting intentional mid-message content.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 7:30 AM ET / 11:30 UTC.

ClawSweeper review

What this changes

The PR removes only leading OpenClaw-generated inbound metadata from assistant reply text before reply directives are parsed, and adds regression tests for directive preservation and intentional later metadata examples.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This remains a focused candidate fix for the linked outbound metadata-leak problem. The branch now uses the leading-only sanitizer, preserving intentional metadata examples after visible text and avoiding the earlier timestamp/broad-removal concerns; the PR also contains exact-head mock-gateway proof. It should stay open for a maintainer to refresh the three-way merge and required lint gate before landing.

Priority: P1
Reviewed head: 9950eb61daa9807cddb4032105d3a1acff61890e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch is a focused, proof-backed repair with earlier sanitizer-scope concerns addressed; only exact merge-head validation remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides exact-head real behavior evidence through mock-openai, an ephemeral Gateway, and qa-channel, with the delivered text recorded after the two leading metadata blocks were removed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides exact-head real behavior evidence through mock-openai, an ephemeral Gateway, and qa-channel, with the delivered text recorded after the two leading metadata blocks were removed.
Evidence reviewed 5 items Narrow delivery-boundary change: The proposed runtime change applies stripLeadingInboundMetadata before parseReplyDirectives, so only echoed metadata at the beginning of a reply is removed while later examples remain deliverable.
Regression coverage: The added tests cover leading Location and Plugin context removal before reply-target parsing and preservation of a marked metadata example that follows visible reply text.
Prior concerns addressed: Earlier review comments identified timestamp stripping and removal of intentional mid-message examples; the current diff calls the leading-only sanitizer and adds coverage for the latter behavior.
Findings None None.
Security None None.

How this fits together

The outbound payload planner converts an agent’s reply into text, reply targets, media, and other channel-ready instructions. Sanitizing at this shared boundary protects Telegram, Discord, and other channel deliveries before their adapters render the reply.

flowchart LR
  A[Model reply payload] --> B[Outbound delivery planner]
  B --> C[Leading inbound metadata sanitizer]
  C --> D[Reply and media directive parser]
  D --> E[Channel-ready payload]
  E --> F[Telegram Discord and other channels]
Loading

Before merge

  • Resolve merge risk (P1) - The branch base predates current main and GitHub reports mergeability as unknown; before landing, refresh the actual three-way merge and rerun the required lint gate on the resulting head.
  • Resolve merge risk (P1) - Because this shared transform runs immediately before channel delivery and directive parsing, the merge check should confirm that reply targets, media directives, and intentional leading user-visible text remain unchanged outside generated metadata prefixes.
  • Complete next step (P2) - A maintainer should refresh the three-way merge and required lint result; no discrete source defect remains for an automated repair lane.
Agent review details

Security

None.

PR surface

Source +1, Tests +38. Total +39 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 38 0 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 40 1 +39

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/infra/outbound/payloads.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #39847
Summary: This PR is the active candidate fix for the canonical outbound echo-contamination report; the closed related PRs are earlier superseded attempts rather than replacements.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Refresh and validate the merge head (recommended)
    Rebase or validate GitHub’s three-way merge result, then rerun the required lint gate and focused outbound tests before merging the shared delivery-path change.
  2. Pause the PR
    Pause only if the current merge result changes directive or channel-delivery semantics beyond the tested leading-metadata removal.

Technical review

Best possible solution:

Land the narrow leading-only sanitizer after rebasing or otherwise validating the actual merge result, with the focused outbound tests and required lint job green on that exact head.

Do we have a high-confidence way to reproduce the issue?

Yes for the proposed path: the PR supplies an exact-head ephemeral-Gateway qa-channel run with echoed leading metadata and confirms that only the visible reply was delivered. This review did not independently execute that scenario.

Is this the best way to solve the issue?

Yes: using the existing leading-only sanitizer at the shared outbound planning boundary is narrower than per-channel filtering and directly preserves directive parsing and later intentional examples.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 95df2dfd6a61.

Labels

Label justifications:

  • P1: The affected shared delivery path can expose internal metadata to users in channel replies.
  • merge-risk: 🚨 message-delivery: The patch changes text immediately before reply-target and media directives are interpreted for every channel.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides exact-head real behavior evidence through mock-openai, an ephemeral Gateway, and qa-channel, with the delivered text recorded after the two leading metadata blocks were removed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head real behavior evidence through mock-openai, an ephemeral Gateway, and qa-channel, with the delivered text recorded after the two leading metadata blocks were removed.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change affects user-visible Telegram reply text, and a Telegram Desktop before/after recording is a direct supplemental proof path.

Evidence

What I checked:

  • Narrow delivery-boundary change: The proposed runtime change applies stripLeadingInboundMetadata before parseReplyDirectives, so only echoed metadata at the beginning of a reply is removed while later examples remain deliverable. (src/infra/outbound/payloads.ts:235, 9950eb61daa9)
  • Regression coverage: The added tests cover leading Location and Plugin context removal before reply-target parsing and preservation of a marked metadata example that follows visible reply text. (src/infra/outbound/payloads.test.ts:57, 9950eb61daa9)
  • Prior concerns addressed: Earlier review comments identified timestamp stripping and removal of intentional mid-message examples; the current diff calls the leading-only sanitizer and adds coverage for the latter behavior. (src/infra/outbound/payloads.ts:235, 9950eb61daa9)
  • Real behavior proof: The PR body records an exact-head mock-openai, ephemeral Gateway, and qa-channel run whose observed delivery was exactly “Visible reply delivered unchanged.” after two leading metadata blocks were removed. (9950eb61daa9)
  • Current review context: A repository member requested a current-head re-review on July 31, 2026 after the exact-head proof was added; the PR therefore has active maintainer engagement and is not a stale-close candidate.

Likely related people:

  • vincentkoc: A repository member requested the current-head Telegram proof and re-review, making them the clearest current routing contact for the remaining merge and validation decision. (role: recent reviewer; confidence: high; files: src/infra/outbound/payloads.ts, src/infra/outbound/payloads.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or inspect the actual three-way merge result and rerun the required lint gate on that exact head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-05T17:27:21.849Z sha 94781b4ef093d23d3d3bf469258d879f455c8728 :: needs changes before merge. :: [P1] Rebase onto the current outbound planner | [P1] Preserve the current sanitizer sentinel set | [P2] Remove the release-owned changelog edit
  • reviewed 2026-07-05T17:55:54.394Z sha 94781b4ef093d23d3d3bf469258d879f455c8728 :: needs changes before merge. :: [P1] Rebase onto the current outbound planner | [P1] Preserve the current sanitizer sentinel set | [P2] Remove the release-owned changelog edit
  • reviewed 2026-07-09T06:11:59.286Z sha 94781b4ef093d23d3d3bf469258d879f455c8728 :: needs changes before merge. :: [P1] Rebase onto the current outbound planner | [P1] Preserve the current sanitizer sentinel set | [P2] Remove the release-owned changelog edit
  • reviewed 2026-07-09T07:01:02.658Z sha 94781b4ef093d23d3d3bf469258d879f455c8728 :: needs changes before merge. :: [P1] Rebase onto the current outbound planner | [P1] Preserve the current sanitizer sentinel set | [P2] Remove the release-owned changelog edit
  • reviewed 2026-07-31T03:32:38.342Z sha 94781b4ef093d23d3d3bf469258d879f455c8728 :: needs changes before merge. :: [P1] Rebase onto the current outbound planner | [P1] Retain current sanitizer protections | [P2] Remove the release-owned changelog entry
  • reviewed 2026-07-31T08:15:35.470Z sha 9950eb61daa9807cddb4032105d3a1acff61890e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T08:21:06.243Z sha 9950eb61daa9807cddb4032105d3a1acff61890e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T11:25:00.247Z sha 9950eb61daa9807cddb4032105d3a1acff61890e :: needs maintainer review before merge. :: none

@p3nchan
p3nchan force-pushed the fix/strip-inbound-metadata-outbound-delivery branch from 27b4344 to 2bb1de9 Compare May 2, 2026 05:05
@p3nchan

p3nchan commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed in 2bb1de94b6 — rebased onto current main, closed duplicate #51653 as superseded, and kept this as the canonical #39847 fix.

Review response:

  • Replaced the broad outbound stripInboundMetadata() call with stripLeadingInboundMetadata() at the outbound plan boundary before directive parsing.
  • Preserved the shared stripInboundMetadata() timestamp-only semantics; the stale branch commit that changed that contract is reverted in this refreshed history.
  • Added focused coverage for directive parsing after leading metadata stripping, timestamp-prefixed replies without metadata, and metadata-looking examples after normal text.

Local verification passed:

  • pnpm exec oxfmt --check --threads=1 src/infra/outbound/payloads.ts src/infra/outbound/payloads.test.ts
  • pnpm test src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts (70 tests)
  • pnpm test src/gateway/chat-sanitize.test.ts src/tui/tui-formatters.test.ts (41 tests)
  • pnpm check:changed

Pushed with --force-with-lease; CI should re-run on the refreshed branch.

@p3nchan
p3nchan force-pushed the fix/strip-inbound-metadata-outbound-delivery branch from 2bb1de9 to d2a6a68 Compare May 2, 2026 05:47
@p3nchan

p3nchan commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased again onto current main and addressed the remaining ClawSweeper required changes. New head is d2a6a6851edc106340a6f83e25b82394f3a77606.

Additional review response:

Local verification:

  • pnpm exec oxfmt --check --threads=1 src/infra/outbound/payloads.ts src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.ts src/auto-reply/reply/strip-inbound-meta.test.ts CHANGELOG.md
  • pnpm test src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts (71 tests)
  • pnpm test src/gateway/chat-sanitize.test.ts src/tui/tui-formatters.test.ts (41 tests)
  • pnpm check:changed

@p3nchan
p3nchan force-pushed the fix/strip-inbound-metadata-outbound-delivery branch from d2a6a68 to 6af0292 Compare May 2, 2026 06:12
@p3nchan

p3nchan commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased again onto current origin/main and pushed with --force-with-lease.

New head: 6af02926dd424453a4f4d12525d0fc719599104f

Local checks:

  • pnpm exec oxfmt --check --threads=1 src/infra/outbound/payloads.ts src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.ts src/auto-reply/reply/strip-inbound-meta.test.ts CHANGELOG.md
  • pnpm test src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts
  • pnpm test src/gateway/chat-sanitize.test.ts src/tui/tui-formatters.test.ts
  • pnpm check:changed

The only conflict in this refresh was the Unreleased changelog entry; I kept the new upstream entries and retained this PR's Outbound/security note.

@p3nchan
p3nchan force-pushed the fix/strip-inbound-metadata-outbound-delivery branch from 6af0292 to 86e7d99 Compare May 4, 2026 17:34
@p3nchan

p3nchan commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current upstream/main and addressed the remaining sanitizer coverage items. New head: 86e7d99bf0.

Review response:

  • Preserved current main’s Reply target of current user message (untrusted, for context): sentinel.
  • Extended leading inbound metadata stripping to generated structured labels such as context 1 (untrusted metadata):, not only fixed sentinel names.
  • Added outbound delivery regression coverage for dynamic structured metadata labels in echoed leading LLM text, plus direct sanitizer coverage for stripInboundMetadata and stripLeadingInboundMetadata.
  • Resolved the changelog conflict and kept the Echo contamination: stripInboundMetadata not called in outbound delivery pipeline #39847 fix entry scoped to outbound/security.

Local checks passed:

  • pnpm exec oxfmt --check --threads=1 src/infra/outbound/payloads.ts src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.ts src/auto-reply/reply/strip-inbound-meta.test.ts CHANGELOG.md
  • pnpm test src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts (73 tests)
  • pnpm test src/gateway/chat-sanitize.test.ts src/tui/tui-formatters.test.ts (56 tests)

CI should rerun on the refreshed branch.

@p3nchan
p3nchan force-pushed the fix/strip-inbound-metadata-outbound-delivery branch from 86e7d99 to 94781b4 Compare May 4, 2026 17:39
@p3nchan

p3nchan commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased once more onto the latest upstream/main after main advanced again. New head: 94781b4ef0.

Only conflict in this refresh was the Unreleased changelog ordering; I kept the new upstream Gate zalouser startup name matching entry and retained this PR’s Outbound/security #39847 Fixes entry. The sanitizer/test changes from the previous review response are unchanged.

Local checks passed again:

  • pnpm exec oxfmt --check --threads=1 src/infra/outbound/payloads.ts src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.ts src/auto-reply/reply/strip-inbound-meta.test.ts CHANGELOG.md
  • pnpm test src/infra/outbound/payloads.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts (73 tests)
  • pnpm test src/gateway/chat-sanitize.test.ts src/tui/tui-formatters.test.ts (56 tests)

CI should rerun on the latest branch.

@p3nchan

p3nchan commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Friendly check-in — branch is conflicted again. Latest revision narrows stripping to leading-only metadata per earlier review feedback (ClawSweeper notes no concrete blocker remaining). Happy to rebase if this is still in pipeline; otherwise OK to close.

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 11, 2026
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels May 11, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 16, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 16, 2026 13:31 Inactive
@clawsweeper clawsweeper Bot removed proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 16, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@vincentkoc

Copy link
Copy Markdown
Member

@openclaw-mantis telegram desktop proof: verify on the current PR head that a leading echoed location metadata block is removed while the visible reply is delivered unchanged.

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Exact-head real-behavior proof is now in the PR body: mock provider + ephemeral Gateway + qa-channel passed on 9950eb61daa9807cddb4032105d3a1acff61890e, with verdict JSON included. The two Mantis Desktop attempts failed during baseline/test-chat setup before candidate execution.

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Rebased to current main and pushed as 5b8854e7896ebbd84b98c55c7a4138e4adbd6f50.

The PR body contains the full proof metadata and verdict JSON.

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

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

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Echo contamination: stripInboundMetadata not called in outbound delivery pipeline

2 participants