Repository navigation
fix: prevent internal runtime context from appearing in replies - #163471
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
0a5c00e to
dc443c5
Compare
|
Codex review: blocked before merge. Reviewed October 3, 2026, 3:57 PM ET / 19:57 UTC (Revision 26). ClawSweeper reviewWhat this changesThe PR separates internal runtime context from user text across model requests, session replay, CLI backends, and workers, and filters context echoes from replies. Merge readiness⛔ Blocked before merge - 1 item remains This remains useful, maintainer-authored work. No blocking introduced defect was identified, and the previous generic config/default compatibility blocker is unsupported by the pinned diff. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw's agent runtime combines user requests with internal facts before sending them to model providers. Provider adapters project that context, while transcript and output owners preserve replay compatibility and control what users see. flowchart TD
A[User requests] --> C[Agent context assembly]
B[Internal runtime facts] --> C
C --> D[Typed context carrier]
D --> E[Provider role projection]
D --> F[Session replay and worker validation]
E --> G[Model response]
G --> H[Filtered user reply]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use one typed runtime-context contract with provider-specific projection, byte-compatible stored replay, and bounded streaming and final-output filtering. Do we have a high-confidence way to reproduce the issue? Yes, source inspection identifies the existing carrier-to-user conversion and delimiter-based streaming boundary; linked reports provide concrete request captures. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes, the shared semantic marker and provider-owned projections address the existing ownership gap while preserving shipped replay contracts; no new configuration knob is needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e7090f6d88be. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (25 earlier review cycles; latest 8 shown)
|
316d528 to
d494c47
Compare
d494c47 to
800b39c
Compare
Stable-line gap: this class still reproduces on v2026.9.9; the fix is not in the 2026.9.x lineThis PR's problem description matches a symptom class we hit in the wild, so this is a gap report against the stable line rather than a new bug report, since the repair already exists here. Environment: self-hosted gateway on Windows, Control UI webchat, versions v2026.9.8 and v2026.9.9 (stable line). Observed:
Release gap (commit ancestry via the compare API, merge commit
Question for maintainers: is a cherry-pick to the 2026.9.x stable line planned, or should affected stable users wait for 2026.10.1? We will re-verify against 2026.10.1 when it ships and report back here. If the tool-call-envelope-as-visible-text variant in observation 2 is considered a distinct output-cleanup bug rather than this class, say so and we will file it separately with a repro. |
What Problem This Solves
OpenClaw runtime context had no single model-facing owner. Producers stored hidden custom messages, the agent harness flattened them into ordinary
usermessages, provider adapters inferred semantics from placement or delimiter text, and output cleanup depended on those same delimiters. Models could therefore treat host context as a new user request, describe it as a prompt injection, or echo internal runtime context into channel replies. The failure spans embedded runs, CLI backends, workers, BOOT, subagent wakes, provider replay, generated-media retry, compaction, and streaming output.Closes #110190.
Closes #162001.
Related reports include #104602, #108409, #115978, #123265, #129314, #136360, #137493, #139022, #141213, #142754, #144944, #151807, and #161697. Related narrower cleanup: #160174. This includes the empty-snapshot direction originally contributed by @Bartok9 there.
User Impact
Why This Change Was Made
The architectural owner is now
RuntimeContextMessage: a compatibility-safeusermessage with nested runtime-context metadata. A separate marker predicate identifies trusted runtime context independently of whether its content is already in a provider-compatible text-only shape. Producers create semantic carriers; the agent harness preserves the discriminant; each provider adapter performs the required role projection; cache retention travels with metadata instead of text markers.The shipped
runtimeContextCarrierfields remain read/write projections during their compatibility window. Marker-only persisted v2026.9.7 records are recognized by one shared classifier across conversion, history cleanup, compaction, cache ownership, request attribution, and decision context. Mixed-media shipped carriers preserve their exact block array locally; worker inference rejects unsupported media context with an actionable local-retry error rather than silently relabeling it as user input.Provider behavior is explicit:
Direct Codex contract inspection supports this ownership model:
../codex/codex-rs/protocol/src/models.rs:797,../codex/codex-rs/core/src/session/inject.rs:70,../codex/codex-rs/core/src/context_manager/history.rs:320, and../codex/codex-rs/core/src/client.rs:850show client-authored developer input retained and forwarded separately from user messages.Judged LOC delta against the merge base:
The production growth is the cross-package discriminant, provider/CLI/worker projections, bounded output defense, and shipped-compatibility handling replacing implicit string/placement policy across 30+ production modules. Current delimiter construction and duplicate carrier classifiers are removed; legacy handling is bounded to shipped transcript shapes.
Evidence
Exact candidate head:
031b446d6d95ec9c70e487a0bb3e71c1631d3e36.OpenClaw runtime contthrough the production projector and subscription path. After repair, the 126-test sanitizer/codec/subscription acceptance set passed.pnpm test:changed— all 16 selected shards passed on the rebased branch (including 1128 tooling tests, 355 infra tests, 231 agents-core tests, 141 provider-extension tests, and every remaining project shard).pnpm check:changed— the full changed gate passed after rebase. Every post-review repair also passed its path-scoped formatting, type graphs, deprecated-API, dead-export, lint, database ownership, SDK surface, and import-cycle checks.pnpm openclaw qa suite --provider-mode mock-openai --scenario heartbeat-inbound-metadata --output-dir .artifacts/qa-e2e/runtime-context-carrier— 1/1 passed; runtime context arrived as developer input, no legacy delimiter reached the request, and the channel-visible reply remained clean.pnpm build— passed, including declarations, external plugins, SDK surface, runtime postbuild, and Control UI.@openclaw/llm-coresource alias; the previously failing Custodian suite passed 29/29.6f8ddc75565completed at P0–P2. Its sole P2 was rejected after direct source verification: every active-steering carrier is created throughbuildRuntimeContextCustomMessage, which setstimestamp: Date.now()before materialization, satisfying the worker schema.Set{}vsSet{1}); the provider now uses the shared marker predicate, and OpenAI/Anthropic cache suites pass 58/58.stop/length, the focused lifecycle set passes 21/21, and the full six-suite acceptance set passes 91/91.Cannot add property providerReplay; cloning the snapshot at the fixture boundary passes 12/12, its complete scoped gate, and fresh P0–P2 AutoReview.[user, carrier]pair associated through normalization and provider conversion; the seven-suite acceptance set passes 102/102.main02acc1b9710merged current-main's centralized CLI prompt-context flow with typed runtime fragments and preserved delivery guidance outside the protected carrier. The failed conflict assertion was corrected to require guidance retention plus labeled-carrier placement; the focused CLI cases pass 3/3, the complete conflict-path gate is green, and final committed-head P0–P2 AutoReview is scoped clean.git diff --check— passed.Channel-visible proof uses the mock-gateway harness verdict permitted by the repository policy for this transport-generic provider/sanitizer change.
ClawSweeper Revision 25 rank-up move (config compatibility): skipped as inapplicable. This PR changes no config key, default, schema, validation, setup/startup behavior, fallback, or operator action; shipped transcript/provider compatibility is covered by the version-3/version-4 replay and reopen proofs above.