Repository navigation
#92589: fix(internal-runtime-context): wrap prompt-preface runtime context body in delimiters - #92593
Conversation
…dy in delimiters When buildRuntimeContextMessageContent constructs the hidden runtime context prompt block, the body (which may contain sensitive metadata like relevant-memories, sender info, and conversation metadata) was not wrapped in the standard INTERNAL_RUNTIME_CONTEXT_BEGIN/END delimiters. If the model echoed this context back in its reply, stripInternalRuntimeContext could only remove the header and notice lines — the sensitive body leaked through to user-visible surfaces like Feishu streaming cards. Wrap the runtime context body in BEGIN/END delimiters so the existing stripInternalRuntimeContext (which handles delimited blocks first) can fully remove the entire block. Closes openclaw#92589
|
Codex review: needs maintainer review before merge. Reviewed June 13, 2026, 12:30 AM ET / 04:30 UTC. Summary PR surface: Source +7, Tests +6. Total +13 across 2 files. Reproducibility: yes. source-reproducible. Current main and v2026.6.6 build prompt-preface runtime context with an unwrapped body, while stripInternalRuntimeContext removes delimiter blocks and only the header/notice preface. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow core prompt-boundary fix with the existing tests and passing checks, then let #92589 close after merge. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible. Current main and v2026.6.6 build prompt-preface runtime context with an unwrapped body, while stripInternalRuntimeContext removes delimiter blocks and only the header/notice preface. Is this the best way to solve the issue? Yes. Wrapping at context creation is the narrowest maintainable fix because every user-visible sanitizer path already honors the internal delimiter contract, while a Feishu-only filter would leave other surfaces dependent on heuristics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4a6666796f46. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +7, Tests +6. Total +13 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
proof updated |
…ntime context body in delimiters (openclaw#92593) * fix(internal-runtime-context): wrap prompt-preface runtime context body in delimiters When buildRuntimeContextMessageContent constructs the hidden runtime context prompt block, the body (which may contain sensitive metadata like relevant-memories, sender info, and conversation metadata) was not wrapped in the standard INTERNAL_RUNTIME_CONTEXT_BEGIN/END delimiters. If the model echoed this context back in its reply, stripInternalRuntimeContext could only remove the header and notice lines — the sensitive body leaked through to user-visible surfaces like Feishu streaming cards. Wrap the runtime context body in BEGIN/END delimiters so the existing stripInternalRuntimeContext (which handles delimited blocks first) can fully remove the entire block. Closes openclaw#92589 * chore: retrigger CI for proof check * chore: retrigger CI with corrected proof format * chore: retrigger CI with corrected proof field format
…ntime context body in delimiters (openclaw#92593) * fix(internal-runtime-context): wrap prompt-preface runtime context body in delimiters When buildRuntimeContextMessageContent constructs the hidden runtime context prompt block, the body (which may contain sensitive metadata like relevant-memories, sender info, and conversation metadata) was not wrapped in the standard INTERNAL_RUNTIME_CONTEXT_BEGIN/END delimiters. If the model echoed this context back in its reply, stripInternalRuntimeContext could only remove the header and notice lines — the sensitive body leaked through to user-visible surfaces like Feishu streaming cards. Wrap the runtime context body in BEGIN/END delimiters so the existing stripInternalRuntimeContext (which handles delimited blocks first) can fully remove the entire block. Closes openclaw#92589 * chore: retrigger CI for proof check * chore: retrigger CI with corrected proof format * chore: retrigger CI with corrected proof field format
Summary
Wrap the runtime context body in
buildRuntimeContextMessageContentwithINTERNAL_RUNTIME_CONTEXT_BEGIN/ENDdelimiters sostripInternalRuntimeContextcan fully remove leaked runtime context from user-visible surfaces.Root Cause
buildRuntimeContextMessageContent(inruntime-context-prompt.ts) constructs hidden runtime context prompt blocks using the "prompt preface" format. When the model echoes this context back in its reply,stripInternalRuntimeContextstrips the header and notice lines viastripRuntimeContextPromptPreface, but the body (containing sensitive data like<relevant-memories>,Sender (untrusted metadata),Conversation info) was not wrapped in delimiters thatstripDelimitedBlockhandles. The body leaked through into Feishu streaming cards.Fix: Wrap the runtime context body in
<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>/<<<END_OPENCLAW_INTERNAL_CONTEXT>>>delimiters (3 lines added).stripInternalRuntimeContextalready processes delimited blocks first, so the entire context block is removed.Real behavior proof
Behavior or issue addressed: When a runtime context block (containing
<relevant-memories>,Sender (untrusted metadata),Conversation info, system timestamps) is echoed in a reply,stripInternalRuntimeContextnow completely removes the entire block instead of leaving the context body visible.Real environment tested: Linux x64, kernel 4.19.112-2.el8, Node.js v24.13.1, tsx v4.22.3, openclaw at a0f8095 on top of origin/main (6cf06e8).
Exact steps or command run after this patch:
fix/issue-92589-*branch in openclaw workspacebuildRuntimeContextSystemContextnpx tsx scripts/repro-92589.mjsstripInternalRuntimeContextremoves all sensitive data from a simulated leaked replyEvidence after fix:
Observed result after fix: All sensitive runtime context data (
<relevant-memories>,Sender (untrusted metadata),Conversation info, useropen_id, context header) is completely removed. The actual user-visible reply text is preserved intact. Fix adds 3 lines:INTERNAL_RUNTIME_CONTEXT_BEGIN, the existing body,INTERNAL_RUNTIME_CONTEXT_END.What was not tested: Live Feishu gateway with streaming cards (requires API keys and real channel setup). Verified via production-import tsx execution and existing test suite.
Regression Test Plan
runtime-context-prompt.test.ts— 21/21replay-history.test.ts— passedsanitizeuserfacingtext.test.ts— 142/142internal-runtime-context.test.ts— 5/5AI-assisted: built with Claude Code