Repository navigation
fix(agents): preserve post-compaction continuation prompts - #136236
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: blocked before merge. Reviewed September 4, 2026, 12:50 PM ET / 16:50 UTC. ClawSweeper reviewWhat this changesThe PR makes OpenAI Responses compaction continuation a session-owned prompt overlay, adds chained-retry regression coverage, and reuses a shared SSE test helper. Merge readiness⛔ Blocked before merge - 5 items remain Keep open: the prior P1 finding is fixed at the current head, and the member-authored PR carries the protected Priority: P1 Review scores
Verification
How this fits togetherThe embedded agent runner converts an operator prompt and model output into successive provider requests and a visible answer. A compaction checkpoint requires an internal continuation prompt that must remain present through invisible retries. flowchart LR
A[Operator prompt] --> B[Embedded agent runner]
B --> C[Session prompt state]
C --> D[Model request]
D --> E[Compaction or invisible retry]
E --> C
D --> F[Visible final answer]
Decision needed
Why: The Before merge
Agent review detailsSecurityNone. PR surfaceSource +15, Tests +157. Total +172 across 22 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the session-owned overlay and explicit terminal release, then merge after protected maintainer review confirms the exact-head Gateway regression and required checks. Do we have a high-confidence way to reproduce the issue? Yes: the focused Gateway test defines a deterministic compaction → reasoning-only → visible-answer path that would expose the prior overwrite; this read-only review did not execute it. Is this the best way to solve the issue? Yes: composing the retained continuation in the session prompt owner prevents later retry guidance from replacing it while preserving the terminal release boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 166ce1a8ebd2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
0b6b331 to
9e91deb
Compare
9e91deb to
cb77a12
Compare
|
@clawsweeper re-review The head now includes a root-cause runtime repair for the compaction replay E2E failure, with owner-level unit coverage, real Gateway proof, and updated production/test LOC metrics in the PR body. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
cb77a12 to
1694df0
Compare
|
@clawsweeper re-review The P1 chained-retry finding is fixed at
The PR body contains the current root cause, production/test LOC, direct protocol evidence, and fresh-main merge proof. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
Backport the canonical session-prompt owner repair from #136236 (fb716dc) for the 2026.9.2 release. Preserve continuation constraints when compaction, reasoning, or empty-result retries replace the active prompt; retain the stronger Gateway replay proof. Validated with original-code failures, 113 owner/sibling tests, the full changed-file gate, independent review, and the rebuilt Gateway E2E. Co-authored-by: Vincent Koc <[email protected]>
…136236) * fix(agents): preserve post-compaction continuation prompts * fix(agents): retain compaction continuation across retries
- openclaw#177050 (07b59a0) persists internal retry prompts as hidden internal_system rows. - openclaw#136236 retained the compaction continuation instruction across later invisible retries because that prompt was not saved. - A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt. - Drop the retained instruction once the internal prompt carrying it is persisted. - Fixes test/gateway-openai-compaction-replay.e2e.test.ts on main.
… native login (#164796) * fix(agents): restore saved history for fresh Claude CLI sessions on a native login A Claude CLI conversation on a native login with no forwarded credential had no history owner, so saved history was refused whenever its Claude session was replaced. The owner is now the account Anthropic's OAuth profile endpoint attests for the exact access token the child Claude would use, rechecked synchronously at every spawn, prompt send and coverage commit against an in-process attestation cache. Rebased onto main as one commit. On main a resumed turn also receives durable reference context and interrupted inputs, so any native turn whose writer replays history now refuses an unattested credential at spawn and send, and a turn that runs without saved history receives no interrupted inputs. SessionManager appends committed by the metadata worker take the host's live owner check on their transaction admission, and a writer that needs the check never advances coverage on a path that cannot ask for it. Co-authored-by: xydigitLybnnnn <[email protected]> * fix(anthropic): withhold prompt hook context when the owner check fails - The UserPromptSubmit hook response that carries the turn's private context now takes the full account-bound check at its final write, not only the stream check. - If that check fails, Claude receives an empty hook response and the saved context is withheld. - Docs: the prompt hook is listed among the points where the native login is rechecked. * fix(anthropic): require an explicit opt-in for native login attestation - Native Claude login attestation now runs only when plugins.entries.anthropic.config.historyRecovery.attestNativeLogin is true. It is off by default, and while it is off history recovery never reads or sends the native token, so a native login keeps the current refusal. - The anthropic plugin manifest declares the setting with a default of false and a UI hint naming the endpoint the token is sent to. - The stream check for control requests is no longer part of the plugin SDK CliBackendExecuteContext type. The host passes it to the bundled Claude runtime the way it passes auth credentials. - Config baseline: the plugin surface grows by these two keys (budget 4527 to 4529). - Removed a duplicate Keychain read test. - Docs: the native login clause names the opt-in and its default. * fix(cli-runner): port native history owner onto main's boundary design - adopt main's async assertReadable and transport-side private history checks - keep the attestNativeLogin opt-in and the in-transaction owner probe - split the private-input runtime tests into cli-runtime.private-input.test.ts - regenerate the config baseline hash * simplify: drop duplicate Keychain readers and same-path native-login tests Folds the two added Keychain readers into the existing ones, removes duplicate and same-path test cases, fixes a prepared-backend leak in prepare-native-history.test.ts, and restores the fresh-recovery-turn, non-native auth env and split secure-storage guards. Production code is unchanged except the reader fold. * refactor(cli-runner): own the native owner-check failure in one place - readNativeOwner treats a login lookup that throws as no owner, so the coverage check (worker probe and host actor memory) keeps rows uncovered and a turn without saved history runs on instead of failing - answerCliHistoryOwnerProbe drops its now-redundant catch - writer exposes checkNativeLoginBoundary directly instead of a forwarder - planCliHistoryBoundary keeps main's inline provider normalization - resolveCliChildEnv comment names the installation target layer too - helper-only cli-history-owner-probe.test.ts replaced by a real SessionManager and boundary case in the native-login suite * test(cli-runner): prove native-login paths found untested by mutation - Add an incognito session case: the host actor path covers a native-login row only while the attested login holds (no test failed when its owner check was removed, trusted or dropped). - Assert a refresh-due turn reads no interrupted inputs; a same-login turn still does (no test failed when the turn read them). - Use a parseable Keychain payload without a usable login in the unusable-payload case, so it pins the readable-but-unusable branch. - Drop four native-login cases and one prepare case whose every caught mutation is caught by a kept case on the same path, and the HTTP 500 row that repeats the HTTP 401 row. * refactor(cli-runner): drop the child env base parameter no caller passes resolveCliChildEnv always reads the Gateway process env; the extraction is now a pure move of the executor's lines. * fix(agents): send a compaction continuation once after it is persisted - #177050 (07b59a0) persists internal retry prompts as hidden internal_system rows. - #136236 retained the compaction continuation instruction across later invisible retries because that prompt was not saved. - A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt. - Drop the retained instruction once the internal prompt carrying it is persisted. - Fixes test/gateway-openai-compaction-replay.e2e.test.ts on main. --------- Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: xydigitLybnnnn <[email protected]>
The 2026.10.6 backport of #177050 (b1e91c4) persists internal retry prompts as hidden internal_system rows, but the line kept #136236's retained compaction continuation instruction across later invisible retries. A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt (test/gateway-openai-compaction-replay.e2e.test.ts, Repo E2E Gateway 2/4). Drop the retained instruction once the internal prompt carrying it is persisted. Partial backport of the session-prompt-state hunk and its test from main 29ce97a (#164796); the rest of that PR is unrelated.
… native login (openclaw#164796) * fix(agents): restore saved history for fresh Claude CLI sessions on a native login A Claude CLI conversation on a native login with no forwarded credential had no history owner, so saved history was refused whenever its Claude session was replaced. The owner is now the account Anthropic's OAuth profile endpoint attests for the exact access token the child Claude would use, rechecked synchronously at every spawn, prompt send and coverage commit against an in-process attestation cache. Rebased onto main as one commit. On main a resumed turn also receives durable reference context and interrupted inputs, so any native turn whose writer replays history now refuses an unattested credential at spawn and send, and a turn that runs without saved history receives no interrupted inputs. SessionManager appends committed by the metadata worker take the host's live owner check on their transaction admission, and a writer that needs the check never advances coverage on a path that cannot ask for it. Co-authored-by: xydigitLybnnnn <[email protected]> * fix(anthropic): withhold prompt hook context when the owner check fails - The UserPromptSubmit hook response that carries the turn's private context now takes the full account-bound check at its final write, not only the stream check. - If that check fails, Claude receives an empty hook response and the saved context is withheld. - Docs: the prompt hook is listed among the points where the native login is rechecked. * fix(anthropic): require an explicit opt-in for native login attestation - Native Claude login attestation now runs only when plugins.entries.anthropic.config.historyRecovery.attestNativeLogin is true. It is off by default, and while it is off history recovery never reads or sends the native token, so a native login keeps the current refusal. - The anthropic plugin manifest declares the setting with a default of false and a UI hint naming the endpoint the token is sent to. - The stream check for control requests is no longer part of the plugin SDK CliBackendExecuteContext type. The host passes it to the bundled Claude runtime the way it passes auth credentials. - Config baseline: the plugin surface grows by these two keys (budget 4527 to 4529). - Removed a duplicate Keychain read test. - Docs: the native login clause names the opt-in and its default. * fix(cli-runner): port native history owner onto main's boundary design - adopt main's async assertReadable and transport-side private history checks - keep the attestNativeLogin opt-in and the in-transaction owner probe - split the private-input runtime tests into cli-runtime.private-input.test.ts - regenerate the config baseline hash * simplify: drop duplicate Keychain readers and same-path native-login tests Folds the two added Keychain readers into the existing ones, removes duplicate and same-path test cases, fixes a prepared-backend leak in prepare-native-history.test.ts, and restores the fresh-recovery-turn, non-native auth env and split secure-storage guards. Production code is unchanged except the reader fold. * refactor(cli-runner): own the native owner-check failure in one place - readNativeOwner treats a login lookup that throws as no owner, so the coverage check (worker probe and host actor memory) keeps rows uncovered and a turn without saved history runs on instead of failing - answerCliHistoryOwnerProbe drops its now-redundant catch - writer exposes checkNativeLoginBoundary directly instead of a forwarder - planCliHistoryBoundary keeps main's inline provider normalization - resolveCliChildEnv comment names the installation target layer too - helper-only cli-history-owner-probe.test.ts replaced by a real SessionManager and boundary case in the native-login suite * test(cli-runner): prove native-login paths found untested by mutation - Add an incognito session case: the host actor path covers a native-login row only while the attested login holds (no test failed when its owner check was removed, trusted or dropped). - Assert a refresh-due turn reads no interrupted inputs; a same-login turn still does (no test failed when the turn read them). - Use a parseable Keychain payload without a usable login in the unusable-payload case, so it pins the readable-but-unusable branch. - Drop four native-login cases and one prepare case whose every caught mutation is caught by a kept case on the same path, and the HTTP 500 row that repeats the HTTP 401 row. * refactor(cli-runner): drop the child env base parameter no caller passes resolveCliChildEnv always reads the Gateway process env; the extraction is now a pure move of the executor's lines. * fix(agents): send a compaction continuation once after it is persisted - openclaw#177050 (6a6f792) persists internal retry prompts as hidden internal_system rows. - openclaw#136236 retained the compaction continuation instruction across later invisible retries because that prompt was not saved. - A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt. - Drop the retained instruction once the internal prompt carrying it is persisted. - Fixes test/gateway-openai-compaction-replay.e2e.test.ts on main. --------- Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: xydigitLybnnnn <[email protected]>
The 2026.10.6 backport of #177050 (b1e91c4) persists internal retry prompts as hidden internal_system rows, but the line kept #136236's retained compaction continuation instruction across later invisible retries. A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt (test/gateway-openai-compaction-replay.e2e.test.ts, Repo E2E Gateway 2/4). Drop the retained instruction once the internal prompt carrying it is persisted. Partial backport of the session-prompt-state hunk and its test from main 29ce97a (#164796); the rest of that PR is unrelated. (cherry picked from commit 236b0c1)
What Problem This Solves
OpenAI Responses can finish an attempt with only a compaction checkpoint and no visible assistant answer. The runner requested a continuation, but split that instruction from the session prompt owner. A later reasoning-only or empty-response retry could then replace the active prompt and silently drop the compaction constraint before the model produced a visible answer.
This PR also consolidates duplicate one-shot OpenAI Responses SSE test writers onto the existing shared fixture.
Root Cause And Fix
Prompt identity, persistence, and prepared-user handling belong to
sessionPromptState, while compaction continuation was previously appended from separate retry state during dispatch. The first repair moved it into the active prompt, but represented it as the same replaceable value used by later retry instructions.The canonical fix keeps one session-owned prompt model with two components:
Reasoning-only, missing-assistant, and empty-response retries replace only the base instruction. Visible or terminal resolution clears the retained overlay before any final-revision prompt is installed. The original operator prompt is never replayed because the compaction checkpoint already owns it.
User Impact
Compaction-only OpenAI Responses attempts now retain their continuation constraint through chained invisible retries and continue to a visible final answer.
Evidence
Exact head:
e3305f44a7eb4f5124d5ef3b9d04deefb2df5fdd6a97159ececbf6c0f5a2180b97d761ba1c5fe4df5f13ce26fc1f6ded7f02c525dd6dc5ab36b76813ClawSweeper Follow-Up
Applied the required rank-up move and P1 finding:
The reported data-model compatibility item is not applicable: this changes ephemeral in-memory prompt composition only. No serialized state, schema, migration, config, protocol, or persistence contract changes.
Test Audit
The regression coverage is split by owner:
The shared SSE helper remains framing-only. Scenario events and behavioral assertions stay local.
Scope
+26/-11(net+15)+309/-152(net+157)+0/-0The production growth is the session-owned overlay and explicit lifecycle release seam; moving it into dispatch or individual retry callers would recreate split ownership.