Skip to content

improve: avoid model-context worker startup delays in tests - #145708

Merged
steipete merged 1 commit into
mainfrom
codex/perf-model-context-workers
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-model-context-workers

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where source-backed functional tests time out while starting the first model-context worker. This reproduced the cold-worker failure in #145665: six async cases exceeded their existing five-second launch deadline on unchanged main source.

Why This Change Was Made

Register the model-context worker with the existing runtime process entrypoint owner and consume that descriptor from its launcher. The shared build and test preparation now compile this worker with the other declared workers. Remove the duplicate explicit build entry and document the ownership, following the existing model-catalog worker pattern.

User Impact

Local and CI tests avoid repeated source-loader startup for model-context reads. The worker keeps its serial pool, cancellation behavior, read contract, and existing packaged output path. Installed Gateways already use compiled workers; this PR does not claim an installed-Gateway latency improvement.

Evidence

  • Linux, Node 26.8.2, fresh module caches, original test order, and identical diagnostic timing wrappers: baseline six async failures/two passes; candidate all eight tests pass. The first model-context read changed from a timeout at 5,003 ms to completion in 869 ms. Existing test deadlines and assertions are unchanged.
  • All 81 relevant tests passed: detached context launch (8), transcript footprint (2), model-context/snapshot contracts (39), worker URL resolution (9), and build configuration (23).
  • Final four-file formatting, diff checks, scoped type-aware lint, core and scripts typechecks, and the worker sidecar guard passed. Independent review found no actionable issues.
  • The runtime package graph emitted the worker at its unchanged installed path, and its syntax check passed. Exact-head CI run34678254638 passed, including the previously failing shard, runtime build, both canonical SDK declaration groups from cache misses, SDK exports, UI, and built CLI checks.
  • Neither local full-build attempt completed uninterrupted: the first stopped on dependency hardlink metadata drift; the retry passed all six core declaration groups and their integrity seal, then exited129 during SDK generation. Hosted SDK generation provides covering proof for the interrupted step. No guards were weakened.
  • The subsequent isolated local SDK declaration retry also passed with exit 0, sealed and published normally, and released its task-owned processes. The four reviewed source hashes remained unchanged.

The diagnostic benchmark is a local artifact. No new test mocks, prewarming hooks, retry policy, or timeout exceptions were introduced.

@clawsweeper

clawsweeper Bot commented Sep 12, 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 size: XS maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 06:29
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 2:43 AM ET / 06:43 UTC (Revision 2).

ClawSweeper review

What this changes

Compile the session model-context worker through the shared build and test preparation registry so functional tests avoid repeated TypeScript startup delays.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix absent from the inspected main and latest release. No actionable correctness or security defect was found; the previous review also recorded no findings.

Priority: P2
Reviewed head: 6280a5dfd734a9a0f84debf7dfb1d33a0efe9bb0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused integration with the existing preparation owner, credible reported validation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply; the reported cold-cache functional run exercises the changed launcher, but its local benchmark artifact was not independently inspected.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply; the reported cold-cache functional run exercises the changed launcher, but its local benchmark artifact was not independently inspected.
Evidence reviewed 8 items Introduced change and merge boundary: The supplied complete merge-base delta contains only the worker registration, launcher consumption, duplicate build-entry removal, and matching documentation. Raw test-merge parents match the pinned base followed by the exact PR head; its comparison against that base contains the same four paths.
Launcher preserves existing behavior: The launcher now consumes the shared descriptor while preserving maxWorkers: 1, cancellation, the incognito in-process path, request arguments, and the 60-second task timeout. The worker still calls OpenClaw's transcript reader through its existing read fence; this change does not depend on a Codex harness contract.
Existing preparation owner covers the new entry: Build entries derive from every registry descriptor. The Vitest plugin redirects the declaration module to its prepared generation, while standalone and watch runs retain source resolution. The descriptor keeps config/sessions/session-model-context.worker.js as the installed output path.
Findings None None.
Security None None.

How this fits together

Session model-context reads select transcript history for an agent turn using a serial worker pool. The shared entrypoint registry lets package builds and prepared test runs launch compiled workers while standalone source runs retain their existing resolution.

flowchart TD
  A[Session context request] --> B[Serial worker pool]
  C[Shared entrypoint registry] --> D[Package and test preparation]
  C --> E[Worker URL resolution]
  D --> E
  E --> B
  B --> F[Transcript context worker]
  F --> G[Selected conversation history]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +1, Other -2. Total +1 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 7 5 +2
Tests 1 4 3 +1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 4 11 10 +1

Review metrics

Metric Value Why it matters
Reported cold context read 5,003 ms timeout before; 869 ms completion after The controlled comparison targets the startup delay without relaxing existing test deadlines.

Technical review

Best possible solution:

Keep one shared descriptor for package and test compilation while preserving source-mode resolution, installed paths, and serial transcript-read semantics.

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

The source establishes why this worker misses compiled test preparation, and the body reports a controlled cold-cache reproduction. The timing failure was not independently reproduced in this read-only review.

Is this the best way to solve the issue?

Yes: reusing the existing registry fixes the preparation boundary and removes duplicate build metadata without introducing another compilation path or changing test budgets.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs bounded functional-test startup reliability without evidence of an urgent installed-Gateway regression.
  • 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 supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply; the reported cold-cache functional run exercises the changed launcher, but its local benchmark artifact was not independently inspected.

Evidence

What I checked:

  • Introduced change and merge boundary: The supplied complete merge-base delta contains only the worker registration, launcher consumption, duplicate build-entry removal, and matching documentation. Raw test-merge parents match the pinned base followed by the exact PR head; its comparison against that base contains the same four paths. (88d215b940be)
  • Launcher preserves existing behavior: The launcher now consumes the shared descriptor while preserving maxWorkers: 1, cancellation, the incognito in-process path, request arguments, and the 60-second task timeout. The worker still calls OpenClaw's transcript reader through its existing read fence; this change does not depend on a Codex harness contract. (src/config/sessions/session-model-context-worker-runtime.ts:13, 6280a5dfd734)
  • Existing preparation owner covers the new entry: Build entries derive from every registry descriptor. The Vitest plugin redirects the declaration module to its prepared generation, while standalone and watch runs retain source resolution. The descriptor keeps config/sessions/session-model-context.worker.js as the installed output path. (test/vitest/vitest.worker-artifacts.ts:93, 6280a5dfd734)
  • Current main still needs this integration: The inspected main launcher still constructs its descriptor locally from import.meta.url, and its registry has no sessionModelContext entry. This leaves the model-context launcher outside declaration-based test preparation. (src/config/sessions/session-model-context-worker-runtime.ts:12, 9e44dba516e8)
  • Latest release comparison: The supplied latest release, v2026.9.4, also contains the local source-relative launcher rather than the proposed shared registration. (src/config/sessions/session-model-context-worker-runtime.ts:12, 3a9d69db306c)
  • Captured validation and discussion: The supplied body reports Linux/Node 26.8.2 cold-cache comparison: six async failures before, all eight cases passing afterward, and first-read completion in 869 ms versus a 5,003 ms baseline timeout. It reports 81 relevant passing tests and unchanged deadlines/assertions; the full build retry remained pending. The local benchmark artifact was not supplied for inspection. The related open Markdown PR, improve: format long list-heavy reports faster #145665, provided discovery context but addresses a separate renderer performance problem. (6280a5dfd734)

Likely related people:

  • steipete: 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-12T06:37:50.204Z sha 6280a5d :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 398e107 into main Sep 12, 2026
264 checks passed
@steipete
steipete deleted the codex/perf-model-context-workers branch September 12, 2026 07:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 12, 2026
Main independently landed the same worker registry consolidation in #145708. Keep its canonical registration and remove the duplicate introduced by Git integration; all three worker registration/build files now match main exactly.
steipete added a commit that referenced this pull request Sep 12, 2026
…145541)

* fix: avoid full agent copies during schema version preflight

Read agent schema metadata through the existing bounded read-only child while retaining source admission and native close ownership. Keep full validation and required private snapshot paths unchanged. Accepted storage scope: #145412.

* fix: preserve source inspection lock tolerance

Keep the existing 30-second source-reader wait, prove an exclusive rollback writer can release after eight seconds without refusing an update, and reuse Kysely and the existing schema-version/transaction owners. No timeout or SQL guard exceptions are added.

* fix: keep schema inspection out of lightweight version imports

Keep the version reader byte-identical to its prior lightweight contract. Header inspection retains Kysely and the deferred transaction owner, with read-only PRAGMAs owned by the existing SQLite configuration boundary. Full neutral Linux package build, native lock tests, and large-store proof pass without changing budgets or allowlists.

* test: preserve ownership admission during header preflight

Cover config-only ownership admission for all six agent roles after integrating the current startup isolation owner. Header-only inspection must not skip copied-owner refusal or alter source bytes.

* fix: share the model context worker entrypoint

Let runtime launch, packaged output, and precompiled test workers consume one declaration. This removes measured cold TypeScript loading from functional worker proof without increasing deadlines or changing the worker's source or installed path.

* fix: retain only the upstream context worker registration

Main independently landed the same worker registry consolidation in #145708. Keep its canonical registration and remove the duplicate introduced by Git integration; all three worker registration/build files now match main exactly.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…penclaw#145541)

* fix: avoid full agent copies during schema version preflight

Read agent schema metadata through the existing bounded read-only child while retaining source admission and native close ownership. Keep full validation and required private snapshot paths unchanged. Accepted storage scope: openclaw#145412.

* fix: preserve source inspection lock tolerance

Keep the existing 30-second source-reader wait, prove an exclusive rollback writer can release after eight seconds without refusing an update, and reuse Kysely and the existing schema-version/transaction owners. No timeout or SQL guard exceptions are added.

* fix: keep schema inspection out of lightweight version imports

Keep the version reader byte-identical to its prior lightweight contract. Header inspection retains Kysely and the deferred transaction owner, with read-only PRAGMAs owned by the existing SQLite configuration boundary. Full neutral Linux package build, native lock tests, and large-store proof pass without changing budgets or allowlists.

* test: preserve ownership admission during header preflight

Cover config-only ownership admission for all six agent roles after integrating the current startup isolation owner. Header-only inspection must not skip copied-owner refusal or alter source bytes.

* fix: share the model context worker entrypoint

Let runtime launch, packaged output, and precompiled test workers consume one declaration. This removes measured cold TypeScript loading from functional worker proof without increasing deadlines or changing the worker's source or installed path.

* fix: retain only the upstream context worker registration

Main independently landed the same worker registry consolidation in openclaw#145708. Keep its canonical registration and remove the duplicate introduced by Git integration; all three worker registration/build files now match main exactly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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