Skip to content

fix(agents): avoid model fallback on local transcript conflicts - #165490

Merged
steipete merged 2 commits into
mainfrom
steipete/restart-transcript-cas-20261005
Oct 5, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/restart-transcript-cas-20261005

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated model requests and fallback after a local SQLite transcript conflict, including concurrent writes around a Gateway restart.

User Impact

Eligible appends reread the transcript revision and retry once. An exhausted conflict remains a typed local error: it cannot synthesize an assistant provider failure, rotate accounts, or select a fallback model. A newer user turn remains protected from replies prepared for an older turn. No configuration or persistence migration is required.

Why This Change Was Made

The worker transport lost the transcript conflict class, and the core agent converted thrown local errors into assistant failures. One typed class now survives the storage worker, core agent, attempt normalization, and model-fallback boundary. Normalization rejects it before an earlier compaction result can request another attempt.

The existing transcript owner keeps its bounded local retry and original parent/admission checks. Duplicate constructors and error-name retry matching are removed. Production delta is +60/−43 = +17 lines: the required worker identity and host-to-core classification boundary force that growth; no second retry or persistence path is added. Schemas, durability, retention, permissions, and update behavior remain unchanged.

Evidence

Validated tree: 64c1b61df2eb73a403b65c159dd567a781385850 (head 9f7c58a7a853). Both independent Codex reviews are scoped-clean at P0–P2.

Blacksmith Testbox tbx_01m45jrvx95qw4n603y213v4d5:

  • All 7 new regressions fail on untouched base a9f4080f9749 for the intended defects. All 272 tests pass on the candidate.
  • Recovery measurement: 2 append attempts, 1 revision reread; a second conflict retains its concrete type. Model replay and fallback are refused; newer user input remains intact.
  • node scripts/check-changed.mjs --base a9f4080f9749a14fdd1c7225f341b0941d2b61cb: structural guards, core types, 27 core test graphs, and extension production/test types pass. It stops at inherited unused exports, reproduced identically on the untouched base. The remaining lint and source-policy checks passed in exact-head CI without disabling that guard.
  • Inherited findings: GoogleMeetJoinResult; MemoryWikiImportInsightCluster, MemoryWikiImportInsightsStatus, MemoryWikiOverviewCluster, MemoryWikiOverviewStatus; resolveGatewayWorkboardWorkspaceAccess; MeetingRuntimeOwner. These are in unchanged meeting, wiki, and workboard files.
  • The lease ended during pnpm build with transport exit 255. That manual build is incomplete; the exact-head CI artifact build subsequently passed. The queued replacement lease was stopped unused when CI supplied the remaining proof. Earlier sync failures and a caught test-relocation typo are resolved; the corrected test tree is the one measured below.

Measured with /usr/bin/time -p pnpm test <file> --maxWorkers=1:

Test file Passed Wall time
session-manager-async-message.test.ts 17 32.78 s
session-manager.fork-rebase.test.ts 12 22.63 s
agent-session-models.admission.test.ts 23 22.57 s
openclaw-state-worker-error.test.ts 59 8.01 s
agent-session-transcript-worker.test.ts 3 13.64 s
model-fallback.terminal-boundary.test.ts 22 17.25 s
run.shared-integration.test.ts 136 134.07 s

The two added full-runner cases take 747 ms and 748 ms. They reuse the existing integration harness to prove the public retry boundary; the remainder of that suite is existing coverage.

Exact-head CI passed: run 37291933427 on 9f7c58a7a853, 83 jobs finished with no failures (including expected skips), 551 seconds elapsed. The artifact build passed in 383 seconds. Core/extension lint, additional boundaries, docs, source contracts, and required openclaw/ci-gate statuses are green. Both review passes are clean; all task Testbox leases are stopped. This PR covers local transcript conflict handling; restart discovery and input-admission recovery remain separate campaign work. No live deployment or restart was performed.

Preserve local transcript conflict identity through the storage worker and agent loop. Keep bounded append recovery at the transcript owner, and surface exhausted conflicts without creating provider failures or replaying model work.
Remove two misplaced mock arguments introduced while relocating the transcript conflict regression. The complete candidate tree passes 272 focused tests and all selected typecheck graphs.
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Oct 5, 2026
@steipete
steipete marked this pull request as ready for review October 5, 2026 09:43
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 6:05 AM ET / 10:05 UTC (Revision 2).

ClawSweeper review

What this changes

The PR preserves local transcript-conflict errors across storage workers and agent execution, allowing one eligible append retry while preventing repeated model requests and fallback.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: current main and the latest release lack the complete conflict handling. No actionable introduced defect or unresolved merge blocker was found.

Priority: P2
Reviewed head: 9f7c58a7a85354e61c056b0e1ddbe3a625c152d6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression evidence, successful exact-head CI, and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The author’s verified repository admin role exempts this PR from ordinary external-contributor proof. Reported Testbox coverage exercises the actual transcript owner and worker with concurrent writes, while model-boundary tests use mocks; no live restart was claimed. No stored-data contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author’s verified repository admin role exempts this PR from ordinary external-contributor proof. Reported Testbox coverage exercises the actual transcript owner and worker with concurrent writes, while model-boundary tests use mocks; no live restart was claimed. No stored-data contract changes require migration proof.
Evidence reviewed 11 items Pinned introduction and clean checkout: Reviewed the complete introduced delta from a9f4080 to the original head. The head's raw commit records parent ad2adda and tree 64c1b61df2eb73a403b65c159dd567a781385850, matching the body’s validated tree. Final git status was clean.
Existing retry owner and fences retained: The persistence owner still permits only one revision reread and second append. Prepared-parent validation, writer authority, navigation assertions, and transaction/commit admission remain in place; the patch changes conflict identity rather than granting new authority or changing stored formats.
Local-error propagation and cleanup: The core agent rethrows classified local errors before synthesizing an assistant provider failure, while its finally block still settles queues and streaming state. AgentSession's logical-prompt finally independently publishes agent_settled after failure.
Findings None None.
Security None None.

How this fits together

OpenClaw records agent messages through a SQLite transcript owner and storage workers. Errors returning from that boundary feed agent recovery and model fallback, which must distinguish local persistence conflicts from provider failures.

flowchart TD
  A[Agent messages] --> B[Transcript append owner]
  B --> C[SQLite storage worker]
  C --> D{Transcript conflict?}
  D -->|Eligible first conflict| E[Reread revision and retry once]
  E --> C
  D -->|Exhausted or stale turn| F[Typed local error]
  F --> G[Stop model retry and fallback]
  D -->|No conflict| H[Persisted transcript]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +17, Tests +189, Docs +5. Total +211 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 13 60 43 +17
Tests 6 191 2 +189
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 256 45 +211

Review metrics

Metric Value Why it matters
Production versus test growth production +17 net lines; tests and test support +189 net lines The body justifies production growth through worker error identity and host classification; regressions reuse existing fixtures.

Technical review

Best possible solution:

Keep transcript recovery with its existing owner and propagate exhausted local conflicts without replaying provider work.

Do we have a high-confidence way to reproduce the issue?

Yes, source provides a clear path: a concurrent transcript mutation crosses worker transport and reaches agent failure synthesis or model fallback. The body reports baseline-failing regressions; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Consolidating the conflict class and intercepting it at existing recovery boundaries repairs the owning invariant without adding another retry mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4f05baa4f524.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded agent-recovery repair for concurrent transcript writes, without evidence of a broader runtime outage.
  • merge-risk: 🚨 compatibility: The SDK-backed Agent gains optional local-error classification and different conflict propagation; the narrow repair preserves existing runtime types, exports, settings, and stored formats.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author’s verified repository admin role exempts this PR from ordinary external-contributor proof. Reported Testbox coverage exercises the actual transcript owner and worker with concurrent writes, while model-boundary tests use mocks; no live restart was claimed. No stored-data contract changes require migration proof.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the complete introduced delta from a9f4080 to the original head. The head's raw commit records parent ad2adda and tree 64c1b61df2eb73a403b65c159dd567a781385850, matching the body’s validated tree. Final git status was clean. (9f7c58a7a853)
  • Existing retry owner and fences retained: The persistence owner still permits only one revision reread and second append. Prepared-parent validation, writer authority, navigation assertions, and transaction/commit admission remain in place; the patch changes conflict identity rather than granting new authority or changing stored formats. (src/agents/sessions/session-manager-persistence.ts:375, 9f7c58a7a853)
  • Local-error propagation and cleanup: The core agent rethrows classified local errors before synthesizing an assistant provider failure, while its finally block still settles queues and streaming state. AgentSession's logical-prompt finally independently publishes agent_settled after failure. (packages/agent-core/src/agent.ts:654, 9f7c58a7a853)
  • Worker identity and terminal boundaries: The worker codec reconstructs the concrete transcript-conflict class. Attempt normalization rejects that error before compaction-driven retry, and fallback classifies direct or causally wrapped conflicts as coordination errors before consulting provider policy. (src/state/openclaw-state-worker-error-identity.ts:209, 9f7c58a7a853)
  • Still necessary on current main: Fetched main still handles thrown core-agent errors through handleRunFailure and lacks the explicit transcript-conflict exclusion in resolveModelFallbackError. No merged replacement was established. (src/agents/failover-error.ts:684, 4f05baa4f524)
  • Latest-release check: GitHub's contents endpoint for v2026.9.8 confirms that the released core agent has no isLocalError classifier and sends caught errors to handleRunFailure. A local release-blob read failed, so the release check used the authorized GitHub read endpoint. (packages/agent-core/src/agent.ts:622, fc23bc864e45)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-05T09:50:24.309Z sha 9f7c58a :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 6ddf5a6 into main Oct 5, 2026
229 of 230 checks passed
@steipete
steipete deleted the steipete/restart-transcript-cas-20261005 branch October 5, 2026 10:21
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…claw#165490)

* fix(agents): keep transcript conflicts out of model retry and fallback

Preserve local transcript conflict identity through the storage worker and agent loop. Keep bounded append recovery at the transcript owner, and surface exhausted conflicts without creating provider failures or replaying model work.

* test(agents): correct transcript worker model fixtures

Remove two misplaced mock arguments introduced while relocating the transcript conflict regression. The complete candidate tree passes 272 focused tests and all selected typecheck graphs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant