Repository navigation
improve(gateway): reduce CPU spent listing agent-owned sessions - #137745
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 7:20 AM ET / 11:20 UTC (Revision 3). ClawSweeper reviewWhat this changesThe Gateway reuses agent-roster lookup facts during synchronous session selection and each preparation chunk, with tests covering bounded work and configuration freshness. Merge readiness✅ Ready for maintainer review The PR remains useful: current main still repeats roster lookups during session preparation. No introduced correctness or security defect was found; the previous review identified only routine CI follow-up. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway turns stored sessions and configured agent identities into filtered, ordered session lists. Roster batching reduces repeated identity lookups while allowing configuration changes to become visible between synchronous chunks. flowchart TD
A[Session list request] --> B[Stored sessions and agent configuration]
B --> C[Filter and prepare sessions]
C --> D[Reuse roster facts within chunk]
D --> E{More preparation work?}
E -->|Yes| F[Release batch and yield when needed]
F --> C
E -->|No| G[Project ordered session rows]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +208. Total +211 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep roster memoization in its existing owner and scope reuse to synchronous selection or one preparation chunk. Do we have a high-confidence way to reproduce the issue? Yes, source establishes repeated roster traversal through session-owner identity projection on current main; the supplied regression evidence quantifies it, but this review did not execute tests. Is this the best way to solve the issue? Yes, reusing the existing batch owner at synchronous boundaries is a narrow solution that preserves yielding and avoids a second cache lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 32bf352734f0. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Batch synchronous session-owner projections through the existing agent roster index, so selection does not rescan the roster per retained session. Reuse normalized values for main-session aliases and remove the duplicate key builder. Preserve request-scoped freshness, legacy aliases, global scope, and row semantics.
088e7d5 to
20fcb49
Compare
…ssion-list-roster-batch-20260913 * commit 'f513c0f345f7f2514c49ccfbc00adc3f78b9a755': (46 commits) chore(i18n): refresh native locales (#146924) perf(secrets): limit expiry metadata to transient credentials (#146882) fix(ui): preserve queued refreshes during session discovery (#146535) test(ui): wait for quiet scrolling and close named file tabs (#146836) fix(ui): prevent Usage hour filters from freezing during DST (#146919) test(ui): share browser page cleanup across layout fixtures (#146805) ci: balance complete PR runtime test groups (#146916) improve(infra): reduce scheduling work for session notice bursts (#146818) improve: prepare Gateway skill commands asynchronously (#146812) improve(agents): skip unused assistant delivery parsing (#146858) improve(ui): reuse date formatters across timestamp lists (#146789) fix(tests): isolate installer and Docker shell snippets (#146897) test(heartbeat): share explicit channel configuration fixtures (#146853) fix: retain conversation reply claims through write admission (#146866) perf(sessions): bound history reads and stabilize cursor paging (#146770) fix(ui): let slow dashboard downloads finish before recovery (#146881) fix: share Doctor lifecycle coordination with SQLite workers (#146714) fix: retain native session model provenance (#146801) fix: settle embedded transcript repairs before session cleanup (#146842) feat(macos): improve agent navigation and chat layout (#146531) ...
|
Merged via squash.
|
* temp/pr-146799: (70 commits) test: reuse explicit fallback config fixtures (openclaw#146948) fix(computer): return fresh window observations after actions (openclaw#146822) refactor(feishu): remove unreachable requester topic selection (openclaw#146904) improve(gateway): reduce CPU spent listing agent-owned sessions (openclaw#137745) fix(ui): avoid recapturing chat drafts during UI updates (openclaw#146884) fix(ui): show system uptime in the debug overlay (openclaw#146960) fix(retry): honor waits beyond the native timer limit (openclaw#145718) fix(ui): keep chat history idle when run status changes (openclaw#146802) fix(ui): reuse persisted text during chat streaming (openclaw#146831) refactor(qa): share harness drift result construction (openclaw#146903) test(agents): coordinate settings lock contention (openclaw#146949) fix(worker): avoid repeatedly serializing screenshot history (openclaw#146907) fix(secrets): stop buffered upload writes after cancellation (openclaw#146840) perf(doctor): avoid unnecessary state runtime imports (openclaw#146926) improve: reduce compaction request estimation work (openclaw#146961) fix(ci): wait for forwarded avatar imports before assertions (openclaw#146729) perf(workers): skip configured Git author lookups (openclaw#146833) fix: admit borrowed memory writes through the agent database owner (openclaw#146760) fix(discord): prevent voice playback gaps and stale turn controls (openclaw#146798) improve: reduce worktree filesystem stalls and archive syncs (openclaw#146906) ...
…claw#137745) * perf(gateway): reuse normalized session and owner facts Batch synchronous session-owner projections through the existing agent roster index, so selection does not rescan the roster per retained session. Reuse normalized values for main-session aliases and remove the duplicate key builder. Preserve request-scoped freshness, legacy aliases, global scope, and row semantics. * test(gateway): isolate roster freshness probe accounting --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Fixes repeated agent-roster scans while the Gateway prepares session lists, adding unnecessary work as configured agents and sessions grow.
User Impact
Session listing does less repeated preparation work while preserving filtering, ordering, visibility checks and cooperative yielding. Configuration changes remain visible between requests and after a yield. No configuration, protocol or storage migration is required.
Why This Change Was Made
Use the existing roster-facts batch at synchronous selection and each generator preparation step. Every batch ends before the next await, so one request cannot retain another request's configuration facts. This keeps memoization at its existing owner.
The remaining production change is +3 lines; tests add 208 net lines. Original contributor head
20fcb497c43b5e88e783a1ffc68b6ac95b8670aeremains an ancestor of signed heada1cbfddfff3dc654ef2eb79fde6366034b53237e. The refresh merges main throughf513c0f345f7f2514c49ccfbc00adc3f78b9a755; it does not duplicate earlier work already on main.Evidence
55f3e3428a89ee82ccd4992b77895d61405d774dfails all three new work-bound assertions after output and freshness checks pass. The synchronous 30-agent fixture reads roster data 2,430 times against its 90-read bound.d3912d33b5af438dd68eb6067f458ea2cf64ef25; the other 20 cases were filtered in that follow-up.5993caceddba4969521714af3d2e9b9953d4bfb602dd2e12782b3539980aee1cand test SHA-256afe6f0a4464d5932369bc8b862db57a77acadc8713583bbe181071ddf288e2c2are unchanged in the refreshed head. The final runtime receipt confirmed both hashes and a clean checkout.These results establish reduced preparation work and preserved freshness, not measured end-to-end Team latency.