Repository navigation
fix: watched-session changes invalidate conversation request prefixes - #182354
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. |
|
Codex review: needs maintainer review before merge. What this changesMoves watched-session membership and titles from the embedded system prompt into the current turn’s runtime context. Example: Rename watched group agent:main:telegram:group:fixture from Original room to Renamed room.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still has the prompt-prefix defect, and this focused repair preserves access checks without introducing an actionable bug. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe embedded runner reads admitted watch targets and session titles, renders bounded awareness text, and passes it through the existing runtime-context carrier into model requests. flowchart LR
A[Watch registry] --> C[Watch snapshot preparer]
B[Session titles] --> C
C --> D[Embedded prompt preparation]
D --> E[Current turn runtime context]
E --> F[Provider request]
G[Retained conversation history] --> F
Technical reviewBest possible solution: Land the focused relocation through the existing watch preparer and runtime-context carrier. Do we have a high-confidence way to reproduce the issue? Current-main source places mutable watched-session facts in the system prompt, and the PR records a negative control failing on that placement; this read-only review ran no target code. Is this the best way to solve the issue? The patch uses the existing preparation, rendering, and turn-context owners, preserves separate SDK and compaction contracts, and explicitly supersedes removed watches with an empty snapshot. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 798570bc460f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +38, Tests +81, Docs +5. Total +124 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed October 26, 2026, 4:49 AM ET / 08:49 UTC (Revision 6). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Signed-off-by: Wesley <[email protected]>
5e06d92 to
0cea440
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#182354) Related: openclaw#114797 ## What Problem This Solves Adding, renaming, or removing watched groups changes the system-prompt suffix ahead of existing conversation history on compatible provider routes. That invalidates an otherwise reusable request prefix. ## User Impact Watched-group awareness stays current without rewriting earlier model context. Existing same-agent, main-session, read-tool, sandbox, and full-prompt visibility checks remain in force. No configuration or migration is required. ## Why This Change Was Made Carry the watch owner's admitted snapshot in the existing current-turn runtime context, including an explicit empty snapshot after the last readable watch disappears. Tool-context refresh accepts the refreshed snapshot without putting it back into the system prompt. The released synchronous SDK and separate compaction prompt keep their existing contracts. The simplification pass retained one watch preparer and one existing runtime-context carrier. Production is +50/-12 (net +38), tests +81/-0, and documentation +5/-0. The remaining growth carries the snapshot and its empty state through those existing owners; no new cache, registry, or persistence owner is introduced. Thanks @ensignwesley for the original repair and regression. ## Evidence - Published head: `1c9cdc778592bb53866ec3b092c794f571f0b3c3`; contributor commits remain intact. - Fresh negative control: the added regression fails against unchanged main production at `9c7a111ce1f035d688e0d3d24864c98d2ad18feb`, specifically because the watched title appears in the system prompt. The failing case took 7.692 s; the cold command took 318.79 s. - Fresh candidate verification: the four exact changed TypeScript blobs from this head passed all 50 tests across prompt preparation, watched sessions, and `agent-tools.prefix-stability.test.ts` in the same tooling checkout. The regression took 5.193 s; total command wall time was 377.17 s, mostly compilation/runner startup. Targeted oxlint and oxfmt passed. These local checks used the tooling checkout's surrounding main code; exact-head CI supplies whole-revision proof. - Exact-head CI run [40279901199](https://github.com/openclaw/openclaw/actions/runs/40279901199) passed, including `openclaw/ci-gate`; the published security/dependency gate also passed. - Prior source-Gateway HTTP proof at `8dbbbf71e18e3dcc71bb6c9c1c45d2fd89788ec2` exercised empty → add → cold reopen/rename → removal across two isolated Gateway processes. System/tool bytes and previous message prefixes stayed identical, current watch facts reached each new turn, and removal supplied an empty snapshot. The three production owners are byte-identical to this head, verified again during this review. - That prior integration also recorded a local Qwen2.5 7B/Ollama control, a full build, targeted types, and `pnpm prompt:snapshots:gen` with zero generated delta. These are retained prior-head results, not newly rerun claims. - Fresh independent Codex review completed with a validated scoped-clean result at P0–P2; no actionable findings. Documentation formatting and a conflict-free merge-tree check against current main also passed. No fresh live Gateway or external-provider run was performed in this pass: the recorded transport proof covers unchanged production bytes, and the fresh checks target the owning regression. No inbound `chat.send`, real channel round-trip, cache-hit-rate, or latency claim is made. Co-authored-by: Wesley <[email protected]>
Related: #114797
What Problem This Solves
Adding, renaming, or removing watched groups changes the system-prompt suffix ahead of existing conversation history on compatible provider routes. That invalidates an otherwise reusable request prefix.
User Impact
Watched-group awareness stays current without rewriting earlier model context. Existing same-agent, main-session, read-tool, sandbox, and full-prompt visibility checks remain in force. No configuration or migration is required.
Why This Change Was Made
Carry the watch owner's admitted snapshot in the existing current-turn runtime context, including an explicit empty snapshot after the last readable watch disappears. Tool-context refresh accepts the refreshed snapshot without putting it back into the system prompt. The released synchronous SDK and separate compaction prompt keep their existing contracts.
The simplification pass retained one watch preparer and one existing runtime-context carrier. Production is +50/-12 (net +38), tests +81/-0, and documentation +5/-0. The remaining growth carries the snapshot and its empty state through those existing owners; no new cache, registry, or persistence owner is introduced.
Thanks @ensignwesley for the original repair and regression.
Evidence
Published head:
1c9cdc778592bb53866ec3b092c794f571f0b3c3; contributor commits remain intact.Fresh negative control: the added regression fails against unchanged main production at
d649e04268584642e16c1775e2e05556b8014ca3, specifically because the watched title appears in the system prompt. The failing case took 7.692 s; the cold command took 318.79 s.Fresh candidate verification: the four exact changed TypeScript blobs from this head passed all 50 tests across prompt preparation, watched sessions, and
agent-tools.prefix-stability.test.tsin the same tooling checkout. The regression took 5.193 s; total command wall time was 377.17 s, mostly compilation/runner startup. Targeted oxlint and oxfmt passed. These local checks used the tooling checkout's surrounding main code; exact-head CI supplies whole-revision proof.Exact-head CI run 40279901199 passed, including
openclaw/ci-gate; the published security/dependency gate also passed.Prior source-Gateway HTTP proof at
8dbbbf71e18e3dcc71bb6c9c1c45d2fd89788ec2exercised empty → add → cold reopen/rename → removal across two isolated Gateway processes. System/tool bytes and previous message prefixes stayed identical, current watch facts reached each new turn, and removal supplied an empty snapshot. The three production owners are byte-identical to this head, verified again during this review.That prior integration also recorded a local Qwen2.5 7B/Ollama control, a full build, targeted types, and
pnpm prompt:snapshots:genwith zero generated delta. These are retained prior-head results, not newly rerun claims.Fresh independent Codex review completed with a validated scoped-clean result at P0–P2; no actionable findings. Documentation formatting and a conflict-free merge-tree check against current main also passed.
No fresh live Gateway or external-provider run was performed in this pass: the recorded transport proof covers unchanged production bytes, and the fresh checks target the owning regression. No inbound
chat.send, real channel round-trip, cache-hit-rate, or latency claim is made.