Skip to content

improve: reduce repeated work when listing sessions across agents - #149057

Merged
steipete merged 2 commits into
mainfrom
codex/perf-catalog-batch-7006
Sep 15, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/perf-catalog-batch-7006

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening or refreshing the session list repeats agent-roster work that grows quadratically with the number of configured agents, including on response-cache hits.

User Impact

Session-list requests do less repeated work as the configured agent count grows, while returning the same session and model information.

Why This Change Was Made

Read prepared catalogs as one synchronous batch after the existing lazy import. The existing roster owner shares derived facts within that batch and discards them before returning. Scalar and batch reads share the catalog projection, and the published scalar interface remains available.

Per-agent failures remain isolated. Reads use published catalogs without initiating provider discovery and continue to observe configuration, catalog, and registry replacement.

Evidence

  • The registered sessions.list comparison preserved all 20 complete response tuples, response-cache object reuse, and catalog/registry replacement behavior.
  • Roster-stage reads per request fell from 5 to 2 for one agent, 3,136 to 64 for 32 agents, and 49,408 to 256 for 128 agents. These are controlled work counts, not end-to-end latency measurements.
  • All 90 tests across six focused files passed, covering methods/cache behavior, catalog ownership, kernel wiring, and embedded contexts.
  • All 12 selected static checks passed, including formatting, lint, core and three Gateway type graphs, import-cycle and boundary checks.
  • Independent review completed both source passes with no actionable P0–P2 findings.
  • A fresh frozen install, full build, and maintained export guard passed on a dedicated Blacksmith Testbox run. The built source tree exactly matches original candidate 399cc6929287; all observed processes settled, and the lease was stopped. This is proof for that recorded candidate, not a build of the later main integration.

Hosted CI 34966814800 on 399cc6929287 failed six thinking-route auth fixture cases before their route assertions (2,034 passed in that shard). The failing test and runtime/model owners are outside this 11-file diff. Merged #149049 supplies the missing runtime auth-store fixture reader. Current head 9512b14690ec integrates main c0be265998d0, including that repair. Ten complete changed files remain identical; the session handler also incorporates main changes to its separate search path. The catalog patch and incoming main delta are preserved. Exact-head CI34970412573 passed under the maintained current-check selection with no pending checks; eight superseded check entries remain retained. Native landing gates still apply, and the earlier failure remains recorded.

@clawsweeper

clawsweeper Bot commented Sep 15, 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 self-assigned this Sep 15, 2026
@steipete
steipete marked this pull request as ready for review September 15, 2026 11:57
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@steipete steipete closed this Sep 15, 2026
@steipete steipete reopened this Sep 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 9:01 AM ET / 13:01 UTC (Revision 2).

ClawSweeper review

What this changes

Batch prepared model-catalog reads when listing sessions across agents, reducing repeated roster work while preserving per-agent results and the existing scalar reader.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful on current main, and no actionable introduced defect was found. The updated evidence addresses the earlier build/export follow-up; this maintainer-owned PR remains eligible for ordinary landing review.

Priority: P2
Reviewed head: 9512b14690ecd34788dd9ae31da45f2e03d310a9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with useful boundary coverage, preserved compatibility, and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-owned internal optimization. The captured body reports registered sessions.list comparisons preserving 20 response tuples and cache behavior; build evidence covers the original candidate, not the later integration head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-owned internal optimization. The captured body reports registered sessions.list comparisons preserving 20 response tuples and cache behavior; build evidence covers the original candidate, not the later integration head.
Evidence reviewed 9 items Current main still has the repeated read path: At fetched main, sessions.list awaits the scalar catalog reader separately for each configured agent. The batch optimization remains absent.
Latest-release comparison: The supplied latest release, v2026.9.4, exposes the scalar prepared catalog reader and has no batch reader.
Bounded batching through the existing owner: The batch reader captures configuration after the lazy import, performs synchronous per-agent reads, and isolates individual failures. The existing roster owner restores its previous batch state in finally; no persistent cache or discovery operation is added. This is an OpenClaw catalog-projection change with no dependency on a Codex runtime contract.
Findings None None.
Security None None.

How this fits together

The Gateway combines stored sessions with each agent’s published model information to answer session-list requests. This change batches the catalog reads before session projection and response-cache selection.

flowchart TD
  A[Session-list request] --> B[Select configured agents]
  B --> C[Batch published catalog reads]
  D[Current configuration and roster facts] --> C
  C --> E[Per-agent catalog results]
  E --> F[Session projection and cache]
  F --> G[Session-list response]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +83, Tests +112. Total +195 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 9 104 21 +83
Tests 2 120 8 +112
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 224 29 +195

Review metrics

Metric Value Why it matters
Request-context compatibility 1 optional batch reader; existing scalar reader retained Older host contexts continue through the scalar fallback without requiring a new RPC or configuration setting.
Reported roster work 128 agents: 49,408 → 256 roster-stage reads The captured comparison demonstrates the intended work reduction, although it does not measure end-to-end latency.

Technical review

Best possible solution:

Use the existing roster owner for synchronous batch reads while retaining scalar compatibility, per-agent isolation, and generation-aware response caching.

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

Yes at the source level: current main repeatedly resolves roster facts through scalar catalog reads before cache selection. The PR supplies controlled work counts; this review did not execute the comparison.

Is this the best way to solve the issue?

Yes. Batching through the existing roster owner removes repeated work without adding persistent state, changing catalog ownership, or replacing the supported scalar interface.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded session-list performance improvement for installations with multiple agents.
  • 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 external-contributor proof gate does not apply to this maintainer-owned internal optimization. The captured body reports registered sessions.list comparisons preserving 20 response tuples and cache behavior; build evidence covers the original candidate, not the later integration head.

Evidence

What I checked:

  • Current main still has the repeated read path: At fetched main, sessions.list awaits the scalar catalog reader separately for each configured agent. The batch optimization remains absent. (src/gateway/server-methods/sessions-read.ts:244, e00500a65429)
  • Latest-release comparison: The supplied latest release, v2026.9.4, exposes the scalar prepared catalog reader and has no batch reader. (src/gateway/server-model-catalog.ts:183, 3a9d69db306c)
  • Bounded batching through the existing owner: The batch reader captures configuration after the lazy import, performs synchronous per-agent reads, and isolates individual failures. The existing roster owner restores its previous batch state in finally; no persistent cache or discovery operation is added. This is an OpenClaw catalog-projection change with no dependency on a Codex runtime contract. (src/gateway/server-model-catalog.ts:229, 9512b14690ec)
  • Additive context contract preserves older readers: The plugin-visible request context gains an optional batch reader. The scalar reader remains unchanged, and the adapter falls back to it when the batch capability is absent. Tests cover scalar, batch, and unavailable-owner contexts. (src/gateway/server-methods/shared-types.ts:245, 9512b14690ec)
  • Meaningful session-boundary coverage: The registered sessions.list tests cover response-cache reuse, distinct agent catalogs, registry replacement, completed catalog replacement, isolated read failure, in-place roster changes, and replacement configuration. These tests were inspected, not executed during this read-only review. (src/gateway/server-methods/sessions-read-catalog-scope.test.ts:295, 9512b14690ec)
  • Previous review follow-up and evidence identity: The captured PR body records successful frozen installation, full build, and export guard for original candidate 399cc69 at https://github.com/openclaw/openclaw/actions/runs/34965373071. Tree-object comparison confirmed that ten touched files, including the catalog implementation and public context types, remain identical at the reviewed head; sessions-read.ts differs after main integration. GitHub reports the Testbox lease run as cancelled, consistent with the stated lease shutdown, rather than a successful build workflow. Its log-storage host was blocked to this reviewer, so the detailed build results remain author-reported. This resolves the prior request to record those results without treating them as an exact-head build. (399cc6929287)

Likely related people:

  • Peter Steinberger: Raw commit 238c333 adds src/gateway/server-model-catalog-view.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 238c33347fe0; files: src/gateway/server-model-catalog-view.ts)
  • obviyus: 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-15T12:17:10.460Z sha 399cc69 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 15, 2026
@steipete
steipete merged commit aff65c0 into main Sep 15, 2026
202 of 203 checks passed
@steipete
steipete deleted the codex/perf-catalog-batch-7006 branch September 15, 2026 14:07
@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

gateway Gateway runtime 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: M 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