Skip to content

perf(agents): reuse roster ids per config generation - #183853

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-agent-roster-per-request-20260919
Oct 25, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-agent-roster-per-request-20260919

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session request agent resolution rebuilt the configured roster, projected every entry, normalized every ID, and allocated a new set/list on every lookup even when runtime config had not changed.

User Impact

Repeated session reads do less CPU and allocation work. Agent selection, legacy roster handling, and database admission behavior remain unchanged. No configuration changes or migration are required.

Why This Change Was Made

Move the existing roster-facts owner down to the roster module and let listAgentIds consume it. Published config uses its publication revision; immutable captures use object identity; synchronous batches retain their existing lifetime. Config republication replaces the derived IDs. Unbound mutable configs still derive fresh results.

Only internal ID lists are shared and frozen. Entry projections retain their mutable contract. The existing Plugin SDK facade copies the shared IDs, preserving independently writable arrays across all three public exports; a boundary regression proves mutations do not affect later reads. The internal caller audit found no mutations of returned ID arrays. Production delta is +14 lines: the existing owner moved intact, and the added field/read/store removes repeated roster derivation without adding a second cache or invalidation policy.

Evidence

Acceptance declared in the benchmark: identical IDs, fewer rebuilt lists, lower warm CPU and sampled allocation per lookup. Synthetic 200-agent roster, 10,000 lookups per mode, five batches of 2,000; separate timing and allocation passes. Base 2649110d60a13f32a33a7ae7bc8c242f4abb2bdc. Local host load was approximately 30–60. A reversed-order confirmation measured published CPU at 193.0 ms base versus 0.556 ms candidate; captured CPU was 195.1 ms versus 0.705 ms.

Owner workload Base Candidate
Published: rebuilt lists 10,000 0
Published: main-thread CPU 181.600 ms 0.486 ms
Published: sampled allocation 412,723,800 B 48,160 B
Captured: rebuilt lists 10,000 0
Captured: main-thread CPU 187.374 ms 0.701 ms
Captured: sampled allocation 411,441,040 B 4,120 B

Rerun: node --import ./scripts/tsx.mjs scripts/perf/agent-roster-ids-measure.ts, then separately with --allocations. The script header documents optional base-module selection. This is warm owner attribution, not a whole-Gateway throughput or latency claim. The lane's explicit duplicate-recomputation fast path uses owner proof rather than a long Gateway A/A campaign; no production load was generated.

Regression covers shared immutable IDs, same-object republication removing an agent, rejection of the removed ID, interleaved old captures, and fresh mutable reads after clearing publication.

Pinned-base regression: fails at repeated-list identity as intended (1 failed, 21 skipped; 418.49 s including compiled-worker preparation). Candidate: all 77 tests across five focused files passed in 544 s including worker preparation. The new roster regression took 12 ms and the SDK mutation regression 2 ms.

  • node scripts/run-vitest.mjs src/agents/agent-scope-config.test.ts src/plugin-sdk/agent-scope-runtime.test.ts src/gateway/session-request-agent.test.ts test/scripts/eager-import-closure.test.ts test/scripts/pr-wrapper-source-closure.test.ts --maxWorkers=1: passed.
  • pnpm tsgo:core: passed.
  • Focused production/test/script lint, oxfmt, git diff --check, and scripts/check-export-name-collisions.mts: passed.

The initial baseline setup was invalidated by a source edit during compiler preparation; the reported red/green proof comes from fresh runs with fixed source. PR CI supplies broad validation. Independent subagent review (autoreview route unavailable): no actionable P0/P1/P2 findings. The autoreview helper refused startup because the selected provider route did not match operator configuration; configuration was not changed.

@clawsweeper

clawsweeper Bot commented Oct 25, 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 scripts Repository scripts agents Agent runtime and tooling size: M labels Oct 25, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 25, 2026
@steipete
steipete force-pushed the steipete/perf-micro-agent-roster-per-request-20260919 branch from 5b4c65a to 891a64f Compare October 25, 2026 21:33
@steipete
steipete marked this pull request as ready for review October 25, 2026 21:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T21:45:19.529514Z 891a64f Draft marked ready
ℹ️ 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.

@steipete
steipete merged commit 7c1dfd9 into main Oct 25, 2026
220 of 222 checks passed
@steipete
steipete deleted the steipete/perf-micro-agent-roster-per-request-20260919 branch October 25, 2026 21:57
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
* perf(agents): reuse roster ids per config generation

* fix(plugin-sdk): preserve distinct roster compatibility export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:feature Preliminary submission classification; full source review pending. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant