Skip to content

fix(agents): bound skill delivery and attribute lane admission waits - #194964

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-global-lane-wait-and-skill-delivery-limit-20260919
Nov 8, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-global-lane-wait-and-skill-delivery-limit-20260919

Conversation

@steipete

@steipete steipete commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Automatically selected skills can exceed the worker's aggregate resource budget before inference, then repeat the same deterministic failure through model fallback. Startup diagnostics also label writer and placement admission as global lane waiting, hiding the blocking phase.

Oversized catalogs now produce a working turn within the existing 8 MiB decoded-resource bound. The existing delivery owner prioritizes prompted, explicit, and pinned skills, reserves bounded omission notices, and retains whole instructions where they fit. Otherwise it delivers an explicit unavailability notice. The model is told which supporting files are unavailable and how to continue. Instructions are never silently truncated. Typed delivery-limit errors stop model fallback immediately; publication and transport integrity limits remain unchanged.

Why This Change Was Made

Admission phase transitions update scalar facts on the existing controller admission record. The queue lends its existing entry to that record and retains the same entry for active-holder identity. The revision removes eager holder snapshots, extra task closures, string building, and diagnostic arrays from queue admission. No new timer or cache is introduced. Existing periodic stuck-session reporting and slow-send logging format the facts only when emitting a diagnostic.

Live stuck diagnostics name the lane/group capacity, enqueue position, and up to 64 current holders. Completed slow-send diagnostics retain enqueue counts and cumulative lane/writer/placement durations, including readmission and fallback attempts; they deliberately do not misrepresent current holders as historical blockers. The caller's predictive queue scan is removed. Task duration starts after lane admission, so it does not establish queue-wait duration. No capacity-release leak was found or claimed fixed.

User Impact

A first turn that waits in writer or placement admission is now reported under its real phase instead of global_lane:waiting, deterministic skill-delivery-limit errors fail fast instead of retrying through model fallback, and oversized skill selections are delivered within the worker limit with a model-visible note instead of failing the turn.

Evidence

Measurement

Original main parent: b97bc15cd7afd6eea35c68c6dfb0cc07706a8671. Five A/A timing pairs followed by five AB/BA blocks (ten comparison samples per arm), with allocation measured separately using two A/A pairs and five AB/BA blocks. Identical harnesses run against the original owner source overlay and the revision. Allocation includes sampled collected objects, not merely retained heap. Wall/CPU numbers below come from unprofiled runs.

Owner workload, median Original base Revision Change
Saturated queue wall / 4,096 turns 13.022 ms 12.829 ms -1.48%
Saturated queue CPU / 4,096 turns 23.021 ms 23.130 ms +0.47%
Saturated queue sampled allocation 34.794 MB 35.060 MB +0.77%
Ordinary skill preparation wall / call 10.495 ms 10.870 ms +3.57%
Ordinary skill preparation CPU / call 12.210 ms 12.812 ms +4.93%
Ordinary skill sampled allocation / call 5.195 MB 5.219 MB +0.47%

All median regressions are below 5% and within A/A variation. Queue A/A median halves: wall 12.835/13.076 ms, CPU 23.070/23.383 ms, allocation 34.910/34.783 MB. Queue A/A full ranges were wall 12.656–51.055 ms (one noisy outlier), CPU 21.999–30.243 ms, allocation 34.313–35.253 MB. Ordinary skill A/A median halves: wall 10.673/11.974 ms, CPU 12.004/13.815 ms; allocation range 5.153–5.235 MB. This is a shared-host local measurement, not a production latency claim.

The saturated fixture uses 4,096 synthetic session identities: 32 waves of 32 holders and 96 waiters. Every revision run settles all turns and exposes 3,072/3,072 queued admissions, with no remaining active/queued work. The 13-minute regression reproduces a saturated lane and verifies the real stuck-diagnostic and slow-send output. Ordinary preparation runs 50 calls per sample and preserves all 32 file reads and 1,302,894 payload bytes per call, with zero failures.

The earlier oversized fixture remains synthetic: 150 skills with 11,992,050 source bytes alongside 61,700 unrelated files containing 1,110,600,000 bytes. Its worker regression is rerun on this revision and completes with a clear note. Queue and resource owners do not read a session database or scan unrelated workspace files; no btrfs or 35 GiB database performance claim is made. No production access or data copying was used. Commands and limits are documented in scripts/perf/README.md.

Validation and size

The original fallback, oversized-resource, worker-completion, and attribution regressions fail on the pre-fix owners. Focused queue/controller/watchdog, resources/worker, diagnostics, fallback, and prompt-prefix suites pass. The Control UI dependency is type-only; affected UI unit tests (2) and Chromium diagnostics E2E (1) pass. Codex autoreview of the full revision against the original base is scoped-clean at P0–P2; the reviewer examined source and proof but did not independently execute the project.

Production delta is +153 lines versus the original base, up from +104 in the first revision; test delta is +199. The resource owner simplification removes a redundant byte reduction and avoids decoding instructions that cannot be retained, but the total LOC reduction goal was not achieved. Growth supplies the explicit transition state, optional watchdog projection, bounded cold diagnostic reader, and cumulative attempt accounting. The hot queue/controller path is smaller; moving collection off that path requires those cold readers. No new configuration, cache, schema, protocol version, dependency, or cap increase.

pnpm check:changed --staged --base 8a607d07aa275d48d87bd93d1f884da2545f34ce was run for the revision. It completed with the two inherited gates below and two revision-owned TypeScript errors: a synthetic queue-entry fixture lacked its now-required lane, and the inferred wait array made the optional admission field required. The final change uses the canonical snapshot element type for that existing array, with no runtime behavior change. Core, scripts, and all core-test typecheck graphs pass after those corrections; the seven cancellation tests also pass. All other changed checks passed. The mechanical type annotation and one fixture field follow the clean autoreview; neither changes runtime behavior.

Two broad gates were already red on the exact main parent and remain unresolved main regressions:

CI repair after c433cc0

The previous revision introduced a real static import cycle: command-queue.state.ts → command-queue.types.ts → command-queue.state.ts. The runtime-only cycle guard excludes type edges, so its green result did not cover this defect. The callback and diagnostic timeline now consume CommandQueueWait, a four-field leaf contract in the existing types owner. Queue state implements that contract and still lends its existing entry. No barrel, lazy import, runtime object, or additional diagnostic work is introduced. Madge fails before this repair and both Madge and runtime import-cycle guards pass afterward.

The failed cron test injected its finalization error only when diagnostics reported idle. Main commit ee3ec605a59c859ba0ad68efe9c199481c543b52 / #194907 correctly preserves processing while a controller lease is active, so that fixture stopped injecting its error. The test now targets the recorded completion fact (consumeQueuedTurn) and retains both its rejection and released-admission assertions. The unchanged test reproduces the identical CI failure on the exact main parent b97bc15cd7afd6eea35c68c6dfb0cc07706a8671 (14 pass, 1 fail) as well as the previous PR head. This repairs an inherited main test regression; production cron lifecycle behavior is unchanged.

This follow-up adds two net production type/comment lines and zero net test lines. Previous performance measurements remain applicable to the unchanged queue and resource runtime. Full affected proof: 17 queue/controller/watchdog/diagnostic files pass (264 tests); all seven original CI cron files pass (39 tests), plus the three message-lifecycle tests. Core and all core-test typecheck graphs pass. Both cycle guards pass. Fresh Codex autoreview of this repair is scoped-clean at P0–P2; it reviewed source but did not independently execute tests or verify historical attribution. The exact-parent failure and introducing patch were verified separately. pnpm check:changed --staged --base c433cc0b1c56d8969eac46cf9554557913654017 completed with every gate passing except the same previously proven inherited changelog-attribution and dead-export failures listed above. No new failure signature remains locally.

No merge or automatic merge is requested.

Keep automatically selected skill resources within the existing worker delivery bound with explicit omission notices, and stop model fallback on typed delivery-limit errors. Record actual queue blockers and separate writer and placement admission from global capacity waits.
@clawsweeper

clawsweeper Bot commented Nov 8, 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 gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling labels Nov 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T04:23:32.091689Z 50e0bb7 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a607d07aa

ℹ️ 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".

Comment on lines +329 to +333
const remaining =
SKILL_LIBRARY_MAX_BUNDLE_BYTES -
total -
Math.min(deliveredCandidates.length - index - 1, deliverySlots - skills.length - 1) * 1024;
if (bundleBytes > remaining) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve complete catalogs that already fit the byte limit

When later skills need fewer than 1,024 bytes each, reserving a fixed 1,024 bytes per candidate can unnecessarily discard supporting files from a catalog whose complete contents fit within 8 MiB. For example, a first bundle of 8 MiB - 512 bytes followed by a 100-byte instructions-only skill previously delivered successfully, but now the first bundle exceeds the artificially reduced remaining budget and loses all its supporting files. This makes previously available scripts and references unavailable without an actual aggregate overflow. Determine whether the complete catalog exceeds the limit before reducing resources, or account for the actual remaining resource sizes.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR bounds worker skill delivery with explicit omission notices, stops deterministic delivery-error fallback, and separates lane, writer, and placement wait diagnostics.

Example: A worker turn selects 150 skills totaling 11,992,050 decoded bytes.

  • Before: Preparation exceeds the 8 MiB aggregate limit and fails before inference.
  • After: Delivery retains resources within the limit and supplies explicit notices for omitted supporting files or unavailable instructions.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful owner-directed repair with focused harness coverage, but resource preservation and the introduced import cycle currently block merge.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; supplied evidence reports worker and admission harness results and synthetic owner measurements, without an inspectable shipped-entry-point trace.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Worker turns can fail before inference when automatic skill selection exceeds the delivery limit, and startup diagnostics can misidentify writer or placement waits as lane contention.
Reason: The maintainer-authored direction addresses an evidenced failure using existing owners and explicit model-visible recovery guidance.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this PR addresses current delivery failures and misleading admission diagnostics, but two introduced defects need correction before merge.

Priority: P2
Reviewed head: c433cc0b1c56d8969eac46cf9554557913654017

Before merge

  • Preserve complete catalogs that fit within the delivery limit (P2) - The fixed 1,024-byte reservation can discard supporting files without an actual overflow. With a first bundle of 8,388,096 bytes and a later 100-byte instructions-only skill, the complete catalog totals 8,388,196 bytes and fits below 8,388,608, but the first bundle is compared against 8,387,584 and reduced to instructions only. Existing scripts and references consequently disappear from a previously valid worker turn. Determine actual aggregate overflow before reducing bundles, or account for actual remaining sizes, and add a regression preserving the complete under-limit catalog. The earlier review discussion identifies the same unresolved trigger.
  • Keep queue entry contracts outside the queue state dependency (P2) - This import creates command-queue.types.ts → command-queue.state.ts → command-queue.types.ts because the state module already imports CommandQueueAdmissionOptions. The repository's Madge checker deliberately collects all static import declarations, including type-only imports, and exits unsuccessfully for circular components; the exact-head architecture check reports that failure. Move QueueEntry into an acyclic leaf contract, such as the existing queue types module, and let state and diagnostics consume it without the reverse import.

Findings

  • [P2] Preserve complete catalogs that fit within the delivery limit — src/skills/runtime/resources.ts:329-333
  • [P2] Keep queue entry contracts outside the queue state dependency — src/process/command-queue.types.ts:1

Tests

  • Missing end-to-end proof: The supplied validation exercises production owners in harnesses but does not show a shipped Gateway turn covering oversized delivery and admission attribution.
Agent review details

How this fits together

Selected skill snapshots enter the resource-delivery owner before worker inference, while the execution controller obtains queue capacity, a session writer, and placement admission and exposes their timing to diagnostics.

flowchart TD
  A[Selected skill snapshot] --> B[Resource delivery owner]
  B --> C[Worker inference]
  D[Admitted turn] --> E[Command queue]
  E --> F[Writer and placement admission]
  F --> C
  E --> G[Admission diagnostics]
  F --> G
Loading

Technical review

Best possible solution:

Keep bounded delivery and deferred diagnostics in their existing owners, preserve complete catalogs that fit, and place queue contracts in an acyclic type boundary.

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

Current main exposes the aggregate-overflow failure directly, and source inspection establishes both introduced defects; the PR reports red-to-green owner regressions, but this read-only review executed no target code.

Is this the best way to solve the issue?

The existing resource owner and controller are the appropriate repair boundaries, but conservative byte reservations must not remove valid resources and diagnostic types must not introduce import cycles.

Full review comments:

  • [P2] Preserve complete catalogs that fit within the delivery limit — src/skills/runtime/resources.ts:329-333
    The fixed 1,024-byte reservation can discard supporting files without an actual overflow. With a first bundle of 8,388,096 bytes and a later 100-byte instructions-only skill, the complete catalog totals 8,388,196 bytes and fits below 8,388,608, but the first bundle is compared against 8,387,584 and reduced to instructions only. Existing scripts and references consequently disappear from a previously valid worker turn. Determine actual aggregate overflow before reducing bundles, or account for actual remaining sizes, and add a regression preserving the complete under-limit catalog. The earlier review discussion identifies the same unresolved trigger.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Keep queue entry contracts outside the queue state dependency — src/process/command-queue.types.ts:1
    This import creates command-queue.types.ts → command-queue.state.ts → command-queue.types.ts because the state module already imports CommandQueueAdmissionOptions. The repository's Madge checker deliberately collects all static import declarations, including type-only imports, and exits unsuccessfully for circular components; the exact-head architecture check reports that failure. Move QueueEntry into an acyclic leaf contract, such as the existing queue types module, and let state and diagnostics consume it without the reverse import.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/skills/runtime/resources.test.ts src/skills/runtime/resources.workspace.test.ts --maxWorkers=1
  • pnpm test src/worker/worker.fault-injection.test.ts src/agents/model-fallback.chain-stop.test.ts --maxWorkers=1
  • pnpm test src/agents/embedded-agent-runner/run/lane-controller.test.ts src/agents/embedded-agent-runner/run/lane-controller.group-wait.test.ts src/process/command-queue.test.ts src/process/command-queue.cancellation.test.ts src/gateway/server-methods/chat-send-diagnostics.test.ts --maxWorkers=1
  • pnpm check:madge-import-cycles
  • git diff --check

What I checked:

PR surface

Source +151, Tests +199, Docs +57, Other +154. Total +561 across 29 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 15 221 70 +151
Tests 8 251 52 +199
Docs 3 59 2 +57
Config 0 0 0 0
Generated 0 0 0 0
Other 3 160 6 +154
Total 29 691 130 +561

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression code Production +221/-70, net +151; tests +251/-52, net +199. The added code supplies bounded delivery, phase accounting, deferred diagnostic projection, and distinct overflow, fallback, and admission regressions without adding another runtime owner.

Labels

Label changes:

  • add P2: Worker skill overflow and misleading admission diagnostics warrant a focused repair, with no evidence of an emergency or widespread current outage.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Worker skill overflow and misleading admission diagnostics warrant a focused repair, with no evidence of an emergency or widespread current outage.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 7, 2026, 10:34 PM ET / November 8, 2026, 03:34 UTC.

Restore cron completion fault injection against the recorded completion fact.
@steipete
steipete merged commit 90dfe90 into main Nov 8, 2026
120 of 129 checks passed
@steipete
steipete deleted the steipete/perf-micro-global-lane-wait-and-skill-delivery-limit-20260919 branch November 8, 2026 05:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
…penclaw#194964)

* fix(agents): bound skill delivery and attribute lane admission waits

Keep automatically selected skill resources within the existing worker delivery bound with explicit omission notices, and stop model fallback on typed delivery-limit errors. Record actual queue blockers and separate writer and placement admission from global capacity waits.

* perf(agents): defer admission diagnostic formatting

* fix(queue): keep admission diagnostics on leaf types

Restore cron completion fault injection against the recorded completion fact.
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Release adaptation: backport only the Socket Mode reconnect waiter owner
and focused regression tests; omit the performance harness and main-only
transport documentation addition. Add listener-count assertions for timer
settlement and disconnect cancellation; adjust the test allocation to 41.

Companion dispositions: #198007 is specific to SDK 3.2 callback/abort
semantics and is not applicable to this line pinned to socket-mode 3.1.0.
#197657 retires main allocations; other audit hits (#200523, #197009,
#194964, #184507, #192197, #192051, #190003, #189850) only overlap the
excluded shared perf README. No later #188745 mention through bd692e9.

(cherry picked from commit a1d1da7)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…penclaw#194964)

(cherry picked from commit 90dfe90)

Release adaptation: Select required/pinned/explicit slots before resource tree reads, fill available discovery slots after vanished optional roots, retain existing 8 MiB aggregate hard refusal and whole instructions. Existing SkillResourceDeliveryLimitError retained and added to failover terminal coordination handling. Explicitly excludes source omission/truncation fallback and all lane instrumentation.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 229003c59543ddaa632a853e2032344ae686b805)
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 gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant