Skip to content

refactor: simplify worker and model fallback handling - #152268

Merged
steipete merged 1 commit into
mainfrom
codex/deslop-worker-failures
Sep 19, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/deslop-worker-failures

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #152028.

What Problem This Solves

Worker inference and model fallback have repeated message projections, error metadata handling, and request setup that must be kept in sync.

User Impact

Internal cleanup with unchanged failure messages, retry behavior, delivery semantics, and worker protocol contracts. No configuration or data migration is required.

Why This Change Was Made

Removes 1,004 net production lines, including all replacement helpers and excluding tests, configuration, and documentation. Validated incoming worker messages use their schema-owned shape; outgoing provider messages retain explicit field projection. Error handling reuses existing field readers and shared mappings, while runner inputs and RPC outcome handling share their existing owners.

Live authority checks, cancellation, synchronous inference acknowledgment, replay limits, private error redaction, late session snapshots, and delivery evidence remain intact. Tests gain malformed-content and array/order coverage. The assertion baseline only shrinks where casts were removed.

Evidence

  • 2,305 tests passed across 62 focused files, covering worker/RPC flows, fallback policy, delivery evidence, error classification, and memory maintenance.
  • 15,530 baseline/current differential comparisons matched, including 595 classification corpus rows, exact user copy, nested-error precedence, malformed reasons, and log field omission/order/coalescing.
  • Runtime build, production and test typechecks, lint, formatting, and every selected repository guard passed. Independent P0–P2 review found no remaining actionable issue after the explicit compaction session-key fallback was retained.

All runtime proof used isolated fixtures; no production Gateway was changed.

Compatibility Review

The automated memory-helper data-model flag was checked against the exact diff: storage schemas, versions, field values, and read/write owners are unchanged. No migration is needed. Source and behavior evidence.

@clawsweeper

clawsweeper Bot commented Sep 18, 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 gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 18, 2026
@steipete
steipete marked this pull request as ready for review September 18, 2026 23:51
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 18, 2026, 8:10 PM ET / September 19, 2026, 00:10 UTC (Revision 2).

ClawSweeper review

What this changes

The PR consolidates worker message handling, model fallback logic, and agent-run setup while preserving existing retry, delivery, and error-reporting behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

No actionable introduced defect found. The source and author’s clarification resolve the previous migration concern; this protected, maintainer-authored cleanup remains distinct from the earlier merged fix.

Priority: P3
Reviewed head: 033c8216b568ebd7487cfe37b5fcb93e3e39efde

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent consolidation with useful contract coverage and no actionable findings; the previous compatibility concern is resolved.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor is exempt from ordinary external-contributor proof. Reported fixture and differential checks cover worker projection and fallback behavior; inspected screenshots demonstrate only the earlier merged fix. No material authority change activates an additional proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal refactor is exempt from ordinary external-contributor proof. Reported fixture and differential checks cover worker projection and fallback behavior; inspected screenshots demonstrate only the earlier merged fix. No material authority change activates an additional proof gate.
Evidence reviewed 8 items Introduced scope: Reviewed the pinned merge-base-to-head changes, rather than treating base-branch drift as PR edits. The checkout matches the original PR head; the supplied verified test merge has the pinned base followed by that head as parents.
Previous compatibility concern resolved: The memory predicate retains the existing freshness reader and per-compaction guard. The accounting update still writes the same three fields with identical values and options. This supports the clarification at #152268 (comment); no migration is warranted by these changes.
Worker dispatch preserves authorization and ordering: The shared dispatch helpers retain connection validation, feature gates, matching request validators, typed rejection behavior, and acknowledgment before inference launch. They do not introduce a new authority-bearing value or broaden the permitted methods.
Findings None None.
Security None None.

How this fits together

OpenClaw’s agent runners select models and execute user or scheduled turns. Worker adapters exchange validated requests and responses with the Gateway, which records transcripts and enforces live execution ownership.

flowchart TD
  A[User or scheduled turn] --> B[Agent run setup]
  B --> C[Model fallback selection]
  C --> D[Local or worker execution]
  D --> E[Validated Gateway requests]
  E --> F[Transcript and delivery evidence]
  D --> G[Error classification]
  G --> C
  F --> H[Reply or terminal failure]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -1004, Tests +34, Other -1. Total -971 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 24 780 1784 -1004
Tests 3 83 49 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 3 -1
Total 28 865 1836 -971

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/auto-reply/reply/memory-flush.ts, vector/embedding metadata: src/auto-reply/reply/memory-flush.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain the shared internal owners while preserving closed worker schemas, live authority checks, delivery custody, and existing persisted values.

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

Not applicable: this PR proposes behavior-preserving cleanup, and source review found no introduced defect requiring reproduction.

Is this the best way to solve the issue?

Yes: consolidating repeated projections and setup under existing owners is a maintainable approach, and the inspected changes preserve the relevant contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is internal cleanup with no intended user-visible behavior, configuration, or migration change.
  • 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 maintainer-authored internal refactor is exempt from ordinary external-contributor proof. Reported fixture and differential checks cover worker projection and fallback behavior; inspected screenshots demonstrate only the earlier merged fix. No material authority change activates an additional proof gate.

Evidence

What I checked:

  • Introduced scope: Reviewed the pinned merge-base-to-head changes, rather than treating base-branch drift as PR edits. The checkout matches the original PR head; the supplied verified test merge has the pinned base followed by that head as parents. (033c8216b568)
  • Previous compatibility concern resolved: The memory predicate retains the existing freshness reader and per-compaction guard. The accounting update still writes the same three fields with identical values and options. This supports the clarification at refactor: simplify worker and model fallback handling #152268 (comment); no migration is warranted by these changes. (src/auto-reply/reply/agent-runner-memory.ts:1360, 033c8216b568)
  • Worker dispatch preserves authorization and ordering: The shared dispatch helpers retain connection validation, feature gates, matching request validators, typed rejection behavior, and acknowledgment before inference launch. They do not introduce a new authority-bearing value or broaden the permitted methods. (src/gateway/server/ws-connection/worker-connection-dispatch.ts:129, 033c8216b568)
  • Transcript contract remains owned by the schema: Incoming transcript messages use the unchanged closed protocol schema before cloning. Redaction, deterministic idempotency keys, session-generation checks, and synchronous pre-commit authority checks remain in place; outgoing provider messages still use explicit field projection. (src/gateway/worker-environments/transcript-commit.runtime.ts:220, 033c8216b568)
  • Current-main and release comparison: Fetched main still contains the separate maintenance predicate and terminal-message projection consolidated here. The new shared assistant projection file is absent from both fetched main and v2026.9.4, so the cleanup is not already implemented by those revisions. (src/worker/assistant-message-projection.ts:1, c9584688c461)
  • Related merged work establishes the baseline: GitHub confirms fix: preserve model failure causes and worker fallback runtime #152028 merged on September 18. Its worker failure and runtime-preservation fix is the baseline for this cleanup, not a replacement for it. Its downloaded before/after screenshots were inspected and show the earlier error-copy improvement. (3fceb86048c4)

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-09-18T23:59:41.495Z sha 033c821 :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Reviewed the automated data-model flag against the exact diff at 033c8216b568ebd7487cfe37b5fcb93e3e39efde: no persistent data model or vector/embedding metadata changes are present.

memory-flush.ts only consolidates the existing maintenance predicate. It still reads the same SessionEntry fields through the unchanged resolveFreshSessionTotalTokens owner, including the same freshness/version checks, and preserves the per-compaction flush guard. The diff is empty for src/config, src/infra/sqlite, src/memory, and packages; there is no schema, migration, serializer, embedding, or storage-version edit. The adjacent runner writes the same three token-accounting fields with unchanged values and update options; it now shares that patch object.

Existing proof includes the passing memory-flush, memory-flush-session, agent-runner-memory, stale-token preflight, and private-transcript suites. Those exercise persisted fresh/stale usage, compaction-cycle guards, transcript accounting, cancellation, and retained session state. No migration is needed because the stored representation and its readers/writers remain unchanged. The path-based compatibility flag is resolved by this source and behavior evidence; the review reports no actionable code finding.

@steipete
steipete merged commit 084d51d into main Sep 19, 2026
287 checks passed
@steipete
steipete deleted the codex/deslop-worker-failures branch September 19, 2026 00:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 19, 2026
* commit 'ca69b4d25dfcd488acc6ba1d878e4b4252f40cd2': (325 commits)
  perf(gateway): streamline config reload comparison (#152279)
  fix(xai): reject invalid UTF-8 OAuth responses (#111737)
  fix(release): accept waived advisory performance evidence for stable publication (#152290)
  fix: deliver watcher results while other sessions are busy (#152287)
  perf(media): reuse attachment filename classification (#152274)
  refactor(build): reuse forwarded option scanning (#152293)
  chore(diagnostics-otel): revert unapproved duration-bucket merge (#152292)
  fix: stop chat media reads after access changes (#152219)
  fix(test): use Gateway WebSocket transport in network fixtures (#152143)
  improve: retain quota refresh evidence from successful CI runs (#152173)
  improve(gateway): reduce memory used by session selection (#152260)
  perf(agents): use keyed subagent capability lookups (#152263)
  refactor(matrix): centralize media metadata assembly (#149128)
  chore(ui): refresh control ui locales (#152276)
  feat: open Crabbox apps beside the conversation (#152094)
  refactor: simplify worker and model fallback handling (#152268)
  perf(codex): reconcile session catalogs incrementally (#152257)
  fix(ui): keep submitted prompts visible across session startup (#152241)
  perf(sessions): move automatic maintenance database work to workers (#148630)
  fix: preserve reply metadata through outbound preparation (#152231)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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