Repository navigation
fix: resume cloud-worker fallbacks from committed history - #177477
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 486e5b1ff5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| suffix.every( | ||
| (entry) => | ||
| entry.type === "message" && readSessionTranscriptRunId(entry.message) === turn.runId, | ||
| ) |
There was a problem hiding this comment.
Handle worker runtime-context rows when resuming fallbacks
On normal non-raw cloud-worker turns, the worker persists an openclaw.runtime-context or openclaw.system-update custom message before the assistant output, but attachSessionTranscriptRunId deliberately adds run ownership only to assistant and tool-result messages. Consequently this predicate rejects the otherwise same-run suffix, leaves baseLeafId at the original admission, and the fallback's next transcript commit still fails with stale-base-leaf—the regression test misses this because it manually commits only assistant/tool-result rows. Account for these worker-owned custom rows, or persist sufficient run ownership on them, when selecting the fallback base.
Useful? React with 👍 / 👎.
|
Landing note for head
All other required checks are green, the fallback, hidden-context and one-read regressions pass, and Codex autoreview is clean. Landing via the inherited-failure admin exception. |
…ory (openclaw#177477) A failover-eligible model error on a cloud-worker turn relaunched the fallback candidate on the original admission base, but the first candidate had already committed its own output under the same run id, so every fallback failed with stale-base-leaf. When the transcript advanced past the admitted entry (checked against the fenced read's snapshot watermark, so normal first attempts still do one transcript read), the fallback now continues from the current leaf if the suffix is entirely this run's assistant/tool-result output plus untagged runtime-context/system-update rows. Any foreign run's rows or user message keep the strict admission fence. Fixes openclaw#161211
Fixes #161211
What Problem This Solves
A cloud-worker fallback can reuse the original admission leaf after the failed candidate committed output, causing
stale-base-leaf. Recorded first attempts also need to avoid a redundant full transcript read.User Impact
Fallback continues from committed assistant/tool output and its accompanying runtime context. Ordinary first attempts use one transcript read. Foreign output, user messages, unrelated custom messages, and non-message entries retain the admission fence. No configuration or migration is required.
Why This Change Was Made
The worker input owner carries the full source version already captured by the fenced model-context read. When its sequence matches the admission, it skips the unfenced read without another lookup or cache. Later writes still face the strict commit check; a metadata-only append can conservatively trigger a suffix read.
When the source has advanced, the fallback accepts only assistant/tool-result rows explicitly owned by this run, plus untagged
openclaw.runtime-contextandopenclaw.system-updatemessages. At least one owned output row is required. Any foreign run ID, user message, unrelated custom type, or other entry type rejects the suffix. Transcript commit checks are unchanged.Custom context rows retain their original metadata. The earlier attempt to tag them globally was reverted because replay and prompt selection also consume run ownership. The exception now lives solely in the worker fallback predicate.
The regression exercises the real fallback runner, launcher, wire projection, and transcript committer with a fake failing worker. It keeps error-only, tool-result, and both runtime-context variants, verifies the one-open common path, and covers rejected suffixes. Wire fixtures use the production projection and typed agent messages without casts. The final diff from the original PR base is +59/−7 production lines, +213/−7 test lines, and +5 documentation lines. This follow-up is +119/−68 across four files.
Evidence
The performance acceptance rule was recorded before measurement: an ordinary recorded first attempt must perform exactly one model-context open, with no added metadata lookup. The two admission fixtures measured 2 opens before and 1 after; both assertions remain in the regression.
stale-base-leafon11d0c854192(72.04 s wall).760a549b3ef: the hidden-system-context test observed the extra__openclawfield (154.23 s wall).pnpm test src/gateway/worker-environments/transcript-commit.test.ts src/agents/embedded-agent-runner/run/attempt.settled-turn-finalization-context.test.ts test/gateway-openai-compaction-replay.e2e.test.ts src/gateway/worker-environments/worker-turn-detached-context.test.ts --maxWorkers=1took 1718.00 s wall, including 21m 33.8s preparing the E2E runtime. The hidden-context and fallback files passed 41/41 (115.78 s Vitest duration); the finalization file had 2 passed, 1 failed (81.11 s). The wrapper stopped before E2E.pnpm test test/gateway-openai-compaction-replay.e2e.test.ts --maxWorkers=1: 64.26 s wall, one failure at line 102 (continuation text occurs twice, expected once).11d0c854192contents, the same assertion failed (50.01 s wall, 2 passed, 1 failed). Main already repairs that stale expectation in 248aa9a5f678, preserving the hiddeninternal_systemprompts required by fix: rate-limited runs lose the prompt cache on retry #177050. No unrelated test or prompt behavior was changed here.11d0c854192contents, then reran the same E2E. It failed at the same line 102 with the same expected-2/actual-3 signature (276.94 s wall, including 3m 47.7s runtime build). Both temporary baseline substitutions were restored exactly afterward. The failing replay expectation remains unresolved here; no assertion was weakened.pnpm test src/sessions/transcript-events.test.ts --maxWorkers=1passed 17/17 (3.75 s wall).node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.gateway-other.json --incrementalpassed (9.71 s wall). This includes the previously failing fixture lines.pnpm run tsgo:corepassed (12.54 s); type-aware lint vianode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.jsonpassed (101.50 s, including artifact-lock wait). Oxfmt andgit diff --checkpassed.node --import ./scripts/tsx.mjs scripts/check-test-mock-exports.mtspassed: 8,220 grandfathered factories (88.06 s wall). No baseline entries were changed.origin/mainatd8bcebf445ecboth contain 460 productionOPENCLAW_*names against a budget of 452. This PR adds none; the budget is unchanged.