Skip to content

improve: reduce blocking skill checks during agent startup - #146373

Merged
steipete merged 3 commits into
mainfrom
codex/perf-async-skill-preparation-7006
Sep 13, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/perf-async-skill-preparation-7006

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Concurrent agent starts can block Gateway requests while synchronously checking skill executables.

Why This Change Was Made

Prepare executable requirements asynchronously with four workers per preparation, reuse successful lookups, and share pending work through the existing skill snapshot owner. Runtime callers await preparation and recheck current run/session authority before publishing snapshots or preparing a sandbox. Synchronous SDK and inventory contracts remain supported.

User Impact

Other requests can resume much earlier during skill preparation. Session edits, replacement, deletion, reset and caller cancellation remain authoritative across the new waits. This is a responsiveness improvement with additional work in some measurements, not a universal throughput or memory improvement.

Evidence

A real Gateway comparison used immutable 00fc6ce versus ba0b96c on WSL/Linux, Node24.19, with four fresh O,C,C,O processes. Each completed eight synthetic turns, eight updates, 64 sampler rounds, 256 history requests and 64 requests per control method, with zero recorded failures and clean Gateway exits.

Metric Original O0 / O3 Candidate C1 / C2
History p95 1,593 / 2,564 ms 151 / 128 ms
Maximum sampled event-loop delay 1,703 / 3,605 ms 241 / 214 ms
Combined load completion 23.48 / 26.08 s 24.94 / 21.12 s
Command-tree CPU 51.69 / 59.49 s 67.93 / 56.20 s
Gateway peak RSS 1,362 / 1,401 MiB 1,386 / 1,397 MiB

The predeclared pairs changed combined completion by +6.2% / -19.0% and CPU by +31.4% / -5.5%. Combined completion joins turns and auxiliary requests; it is not individual-agent latency. Fixed auxiliary counts do not establish identical internal work: mock-provider log counts were 495 / 353 versus 535 / 535. There is no response-body byte-parity, semantic model-output parity or memory-improvement claim. Every readiness sample was degraded. These are synthetic measurements on one host, not production or cross-platform guarantees.

The earlier adaptive comparison also improved responsiveness, but ran roughly three times as many auxiliary probes and had 14–23% longer combined completion with higher raw CPU. It remains retained rather than replaced by the fixed-round result. Historical Windows snapshot-owner measurements (b405e7f versus 85953cb) verified complete snapshot/prompt/consumer parity and 23–29% earlier callbacks, while using 21–33% more CPU and 14% more filesystem probes; same-key preparation was about 8% slower. Differing pre-window RSS prevents an attributable memory claim.

Current head 5f7b24ace4ecc9e7e5d27609e3968d70b4723fd9 is based on 5a4be1f. All three commits remain patch-identical and all 53 async source states match measured ba0. Later canonical integrations are covered by current CI, not relabeled as the measured baseline.

  • Full exact-head CI passed: 114 successful jobs, 17 skips, including the required CI gate, build, types and static lanes. Actual merge 9c1b7b4d preserves all 53 async states. Raw logs verify 131 selected requirement/watcher/snapshot cases, four lifetime cases and 14 upgrade fixture cases.
  • Both required native scanners passed on exact5f7 with unchanged source/dependency inputs and verified process cleanup. Fresh current-head ClawSweeper review found no actionable code/security or before-merge items. Earlier focused correctness/race coverage and independent P2 reviews remain recorded at their original sources.

Historical failed CI remains failed: the 859 lifetime timeout was reproduced locally; ba0 later failed a strict upgrade fixture after a main-origin argument change. Canonical #146508 and #146606 are included; no old failed CI was retried. Earlier invalid Gateway comparisons, degraded readiness, the unattributed ENOTEMPTY cleanup failure, the initial candidate build failure followed by successful ordinary recovery, and rejected-review scope limitations remain preserved in campaign/native evidence. None is relabeled as passing final-head proof.

Related: #145679

@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.

@steipete
steipete marked this pull request as ready for review September 12, 2026 19:43
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 12, 2026
@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, 9:26 PM ET / September 13, 2026, 01:26 UTC (Revision 11).

ClawSweeper review

What this changes

The PR makes agent-startup skill checks asynchronous, shares pending preparations, and preserves current session state across the new waits.

Merge readiness

✅ Ready for maintainer review

This remains useful: current main still performs synchronous skill preparation. No actionable introduced defect was found, and the previous review’s fixture-failure follow-up is resolved by the merged repair.

Priority: P2
Reviewed head: 5f7b24ace4ecc9e7e5d27609e3968d70b4723fd9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent optimization with useful real-owner measurements, focused race coverage, and no actionable correctness finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied historical Windows comparison exercises the actual snapshot owner with real filesystem probes, demonstrates earlier callback execution, and verifies complete consumer parity. Its limits and higher resource costs remain explicit; it does not claim final-head Gateway performance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied historical Windows comparison exercises the actual snapshot owner with real filesystem probes, demonstrates earlier callback execution, and verifies complete consumer parity. Its limits and higher resource costs remain explicit; it does not claim final-head Gateway performance.
Evidence reviewed 10 items Current main still needs the optimization: Fetched main retains synchronous snapshot construction and synchronous executable checks; the requested asynchronous preparation is not already implemented there.
Latest release comparison: The supplied latest-release revision also uses synchronous filesystem executable checks. No shipped implementation of this optimization was established.
Bounded preparation and existing cache semantics: Executable preparation uses four workers, retains successful-hit caching, retries missing tools on subsequent preparations, and detects PATH, PATHEXT, and working-directory changes.
Findings None None.
Security None None.

How this fits together

Skill preparation combines installed skill metadata, executable availability, and session preferences into the instructions available to an agent. Its snapshots feed agent prompts and sandbox skill preparation.

flowchart TD
  A[Installed skills and session preferences] --> B[Skill snapshot owner]
  B --> C{Reusable snapshot?}
  C -->|No| D[Bounded asynchronous executable checks]
  D --> E[Recheck source and caller validity]
  E --> F[Publish skill snapshot]
  C -->|Yes| F
  F --> G[Agent prompt and sandbox preparation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +364, Tests +691. Total +1055 across 53 files.

View PR surface stats
Area Files Added Removed Net
Source 19 573 209 +364
Tests 34 1362 671 +691
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 53 1935 880 +1055

Review metrics

Metric Value Why it matters
Production versus test growth production net +362 lines; tests and harnesses net +693 lines Production growth supports bounded async preparation and reconciliation across waits; test growth covers the resulting lifecycle and cache races.
Measured responsiveness tradeoff callback delay −23–29%; CPU +21–33%; filesystem calls +14% The historical owner-level experiment supports responsiveness gains while explicitly exposing additional resource cost.

Technical review

Best possible solution:

Keep asynchronous preparation within the existing snapshot owner while preserving synchronous inventory contracts, saved prompt bytes, and caller-specific cancellation.

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

Not applicable as a functional bug reproduction; current source establishes synchronous checks, and the recorded real-owner comparison measures their scheduling impact.

Is this the best way to solve the issue?

Yes. The patch extends the existing preparation and snapshot owners, retains shared eligibility rules, and preserves synchronous consumers without adding configuration or changing persisted formats.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a measured startup responsiveness improvement without evidence of an urgent user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied historical Windows comparison exercises the actual snapshot owner with real filesystem probes, demonstrates earlier callback execution, and verifies complete consumer parity. Its limits and higher resource costs remain explicit; it does not claim final-head Gateway performance.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied historical Windows comparison exercises the actual snapshot owner with real filesystem probes, demonstrates earlier callback execution, and verifies complete consumer parity. Its limits and higher resource costs remain explicit; it does not claim final-head Gateway performance.

Evidence

What I checked:

  • Current main still needs the optimization: Fetched main retains synchronous snapshot construction and synchronous executable checks; the requested asynchronous preparation is not already implemented there. (src/skills/runtime/session-snapshot.ts:48, b20b093f4dae)
  • Latest release comparison: The supplied latest-release revision also uses synchronous filesystem executable checks. No shipped implementation of this optimization was established. (src/shared/config-eval.ts, 3a9d69db306c)
  • Bounded preparation and existing cache semantics: Executable preparation uses four workers, retains successful-hit caching, retries missing tools on subsequent preparations, and detects PATH, PATHEXT, and working-directory changes. (src/shared/config-eval.ts:217, 5f7b24ace4ec)
  • Session and cancellation preservation: Snapshot publication checks source freshness and surviving callers; reply persistence checks session identity and lifecycle revision. Integration coverage includes concurrent metadata edits, deletion, replacement, rotation, saved-prompt hydration, and cancellation before environment overrides. (src/skills/runtime/session-snapshot.integration.test.ts:70, 5f7b24ace4ec)
  • Previous review follow-up resolved: GitHub confirms fix(test): align upgrade plugin cohort arguments #146606 merged. Its single expectation repair includes the explicit discord argument, and that repaired expectation is present in the reviewed checkout; the merge commit is an ancestor of HEAD. (test/scripts/upgrade-survivor-plugin-registry.test.ts:357, 01eb021ea972)
  • Re-review source continuity: GitHub’s complete prior-head tree and local HEAD have identical blobs for the snapshot owner, executable checker, skill loader, and reply session updater. The attempted local prior-revision comparison was unavailable; REST tree inspection supplied this bounded comparison. (src/skills/runtime/session-snapshot.ts, 5f7b24ace4ec)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-12T21:48:47.584Z sha 85953cb :: blocked before merge. :: none
  • reviewed 2026-09-12T22:39:22.966Z sha 85953cb :: blocked before merge. :: none
  • reviewed 2026-09-12T22:50:48.194Z sha 85953cb :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T23:14:52.921Z sha 85953cb :: blocked before merge. :: none
  • reviewed 2026-09-12T23:44:55.883Z sha 85953cb :: blocked before merge. :: none
  • reviewed 2026-09-13T00:05:44.509Z sha 85953cb :: blocked before merge. :: none
  • reviewed 2026-09-13T00:20:24.193Z sha 85953cb :: blocked before merge. :: none
  • reviewed 2026-09-13T00:42:20.000Z sha ba0b96c209b16e508f303959c92b60ae27a1f2a1 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/perf-async-skill-preparation-7006 branch from 2fd7d2c to 85953cb Compare September 12, 2026 21:35
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 12, 2026
@steipete
steipete force-pushed the codex/perf-async-skill-preparation-7006 branch from 85953cb to ba0b96c Compare September 13, 2026 00:35
@steipete
steipete force-pushed the codex/perf-async-skill-preparation-7006 branch from ba0b96c to 5f7b24a Compare September 13, 2026 01:20
@steipete
steipete merged commit 4e668c3 into main Sep 13, 2026
192 of 194 checks passed
@steipete
steipete deleted the codex/perf-async-skill-preparation-7006 branch September 13, 2026 01:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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