Repository navigation
Conversation
Co-authored-by: obviyus <[email protected]>
…s append-only Dropping a NO_REPLY row left two user turns adjacent. Chat Completions and Bedrock merge them, which rewrote an already-sent turn and broke the prompt cache. The row is now dropped only when another assistant turn follows (#99620). Co-authored-by: obviyus <[email protected]>
…s append-only OpenClaw-Publication: 0d81101e-150c-8ae4-acbb-e22613e64f78
Worker turns rendered a fresh system prompt every turn. The Gateway now reads the session prompt checkpoint before launch, sends the pinned prefix, stores any change as an appended prompt-update message before the user turn, and writes the checkpoint after the worker commits. No worker protocol change: launch history already carries prompt-update messages. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 2459e91e-8b36-85be-9f3c-3aa5a487b3f4
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. What this changesThis PR retains silent assistant replies as conversation separators and adds session system-prompt pinning for remote worker turns. Example: “Check deployment” receives NO_REPLY, followed by “Any update?”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain Keep open: this maintainer-authored PR addresses a real prefix-stability gap, but the worker integration and two replay-related defects need repair. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway projects stored transcripts and rendered instructions into provider requests, while remote workers return transcript rows that the Gateway commits and finalizes. flowchart LR
A[Stored transcript] --> B[Replay normalization]
B --> C[Gateway prompt preparation]
D[Session prompt checkpoint] --> C
C --> E[Provider or remote worker]
E --> F[Transcript finalization]
F --> A
Technical reviewBest possible solution: Keep the shared replay and prompt-series owners, use indexed lookahead, repair the shrink-history fixture, and connect worker checkpoint reads and delta writes to durable transcript operations. Do we have a high-confidence way to reproduce the issue? Current-main source removes silent separators and rebuilds worker prompts, while the preceding merged PR records the matching prefix breaks; no target code was executed during this read-only review. Is this the best way to solve the issue? Retaining separators and reusing the existing prompt-series owner address the causes, but the worker adapter must consume full checkpoint facts and persist deltas through the durable owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a7d05c7af04a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +197, Tests +381. Total +578 across 11 files. Added test files: 5. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 Reviewed November 13, 2026, 4:30 AM ET / 09:30 UTC. |
|
Converting to draft. Held until the prefix-cache redesign reproduces the causes end to end from captured request bytes and proves a fix on real traffic; this may be superseded by that design. |
|
Closing. The silent-reply half is covered on main (replay keeps the history append-only on routes that do not merge user turns; the remaining merge is a documented known exception, and #201843 covers projected prompt updates). The worker-turn half is still real, but a correct fix needs a worker protocol change to store the prompt-update delta in order. It is tracked in #202523 with measurements. |
Supersedes #198183 (same commits plus the worker pin).
Problem
A deliberate silent reply (
NO_REPLY) broke the prompt cache prefix on role-alternating transports.Remote worker turns rendered a fresh system prompt every turn, so any change (skill, workspace file, tool policy) rewrote the prefix.
Fix 1: silent replies
Fix 2: worker turns use the session pin
src/gateway/worker-environments/worker-turn-system-prompt.tsruns the sameprepareSessionSystemPromptseries as embedded turns. Before launch, the Gateway reads theopenclaw.system-promptcheckpoint and sends the pinned prefix.prompt-updatemessage. The Gateway stores it before the user turn, so stored order matches sent order.finalizeWorkerTurnResult, after the worker's rows are committed. A failed worker turn writes no checkpoint.openclaw.system-updateprompt-updatemessages (WorkerRuntimeContextMessageSchema).One invariant across five transports
New fake servers (
test/helpers/fake-model-transports.ts) speak the five wire formats:anthropic-messages,openai-responses,openai-completions,google-generative-aiandbedrock-converse-stream(Bedrock uses a hand-built AWS event stream). Each transport has its own e2e file that runs one Gateway scenario:first turn → background exec → subagent spawn and completion → inter-session send → skill install → workspace
AGENTS.mdedit → silent turn → next turn → compaction → turn after compaction.The test canonicalizes each request (cache markers removed) and asserts exactly one prefix break, at compaction.
mainDesign references
AGENTS.md:18-21), and asserts breaks withprefix_breaks(tests/e2e/core/history/_helpers.py:214). The e2e assertion here copies that shape: count breaks and allow exactly one, at compaction.agent/surface_switch.py,agent/skills_index_delta.py), and reuses the stored prompt when it still matches (agent/conversation_loop.py:802,:957). Theprompt-updatedelta and the checkpoint restore follow the same idea.packages/agent/src/agent.ts:78-87,packages/ai/src/types.ts). OpenClaw already sends in-history system updates and retained runtime context this way; the fake matrix shows that path holds on all five transports.collapseSystemMessagesrebuild (packages/ai/src/utils/transcript.ts,google-shared.ts:195). Rebuilding the system block on transports without mid-conversation system messages would change the prefix.Evidence
src/agents/embedded-agent-runner/replay-history.test.ts60/60;src/gateway/worker-environments/worker-turn-system-prompt.test.ts3/3 (delta, model-change rebuild, no checkpoint on failure).main, Chat Completions and Bedrock fail at the silent turn.Not in this PR
buildGoogleGeminiReplayPolicy). Removing that needs a live Gemini cache measurement.