Repository navigation
improve: reduce workspace agent lookup work for large fleets - #147144
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, 2:16 PM ET / 18:16 UTC (Revision 4). ClawSweeper reviewWhat this changesReuses agent-configuration facts during each workspace lookup to reduce repeated roster scans, with regression coverage for matching and subsequent configuration edits. Merge readiness✅ Ready for maintainer review This remains a useful, focused optimization absent from current main. No actionable correctness or security findings remain, and the previous review's changed files are unchanged. Priority: P2 Review scores
Verification
How this fits togetherWorkspace inference maps a directory to its configured agent for TUI startup and workspace-aware skills commands. It canonicalizes paths and selects the longest containing workspace, preserving roster order for ties. flowchart LR
A[Current directory] --> C[Canonicalize query path]
B[Agent configuration] --> D[Lookup-scoped roster facts]
D --> E[Resolve and canonicalize workspaces]
C --> F[Choose longest containing workspace]
E --> F
F --> G[Selected agent or no match]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +57. Total +60 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep roster reuse scoped to the synchronous lookup while preserving fresh filesystem checks and configuration visibility between calls. Do we have a high-confidence way to reproduce the issue? Yes, source establishes repeated roster traversal in the current unbatched loop, and the supplied original/candidate measurements exercise that path; this review did not execute it. Is this the best way to solve the issue? Yes, using the existing synchronous batch is a narrow solution that avoids a second cache or a new invalidation policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 83b9a532ef4c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
2891ca4 to
d6ed295
Compare
d6ed295 to
89af761
Compare
89af761 to
9f8b7c1
Compare
|
Merged via squash.
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: improve: reduce workspace agent lookup work for large fleets This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
* commit '28887b564210326174413d0d8ade72b38268d5f3': (1827 commits) fix(qa): bind coverage IDs to producer assertions (#144000) fix(linux): explain FreeBSD desktop setup prerequisites (#147211) fix(memory): split embedding batches rejected for an input array item cap (#139541) test: isolate timing metadata persistence from inherited settings (#147112) refactor(status): retire test-only helper publication (#147071) improve: reduce workspace agent lookup work for large fleets (#147144) refactor(macos): share connect credential selection (#144214) fix(plugins): restore Slack onboarding after core updates (#147109) refactor: share ANSI compatibility matching (#146998) fix(test): settle Models catalog before picker open (#147215) test(ui): reuse panel tab drag fixture (#147250) fix(install): use system Node for FreeBSD CLI setup (#147204) fix(cli): explain MCP probes with no enabled servers (#147216) docs: require UI screenshots in chat and PR (#147263) docs(skills): clarify remote gog OAuth setup for Gateway hosts (#145945) test: replace idle account catalog waits with synchronization (#147228) feat(qa): preserve maturity decision context (#147219) feat(macos): clarify agent activity in native chat (#147197) fix(runtime): complete Bun compatibility follow-ups (#147085) fix(ui): release closed chat panes after queued updates (#147240) ...
Related: #145679.
What Problem This Solves
Choosing an agent from a workspace path repeatedly scans configuration as the agent fleet grows. This adds synchronous work to callers such as TUI workspace selection and workspace-aware skill commands.
User Impact
Large fleets can resolve the same workspace-to-agent match with less roster work. Existing path handling, longest matching root, tie order, and visibility of later workspace edits remain unchanged.
Why This Change Was Made
Run the existing workspace search inside the existing synchronous roster-facts batch. The batch lasts for one lookup; each agent still uses the normal filesystem canonicalization and containment checks. No persistent cache or new invalidation policy is introduced.
Evidence
Missing paths and small fleets had mixed results. At 256 agents, list/explicit/missing was 0.9% slower with 0.6% more CPU on average. At 64 agents, entries/explicit/missing was 3.1% slower with 5.8% more CPU, with both pairs worse. Singleton entries/inherited/existing was 14.8% slower with 10.8% more CPU; no singleton benefit is claimed.
These are two process observations per arm on synthetic Linux fixtures. Real filesystem canonicalization and containment remain inside the measured calls; imports, setup, result checks, and lifecycle checks are outside. A queued-immediate probe and retained return arrays can affect short windows and garbage collection. Process peak RSS ranged 188.6–189.5 MiB across the four processes; this does not establish retained-memory or whole-Gateway/TUI startup gains.
The timing, 178-test result, and original static proof above use fixed
c1191cf5c9b29f617b765216b16ffa992a8bef09source and its actual@openclaw/fs-safe0.10.0 installation. Those measurements were not repeated on later main.Integration on
b076a15e510374bbc73750d0d58bcc4e4025648apreserves main's separately landed runtime-default/data-owner distinction from #146246 and the unchanged workspace batch wrapper. An isolated checkout with an ordinary frozen installation passed both focused suites: 34 tests covering the two large-roster lookup regressions and current owner-selection/inherited-workspace siblings. No test bounds were changed and no full build was repeated. The later patch-identical refreshed head passed exact-head CI; normal native prepare/merge gates remain required before landing.The earlier hosted Control UI gzip failure was also present on main. Separately owned #147116 repaired main's baseline; this PR changes no UI budget or baseline. The subsequent
d6ed2956CI run passed before main's import overlap required the resolved integration above.The subsequent
89af761bintegration run failed only the inherited Workboard unawaited-close lint error and its aggregate gate. Separately owned #147203 fixed that error on main. This branch was then rebased to201f11afefdb19a9c75e9d3542bf7425c80df7a7: the commit is patch-identical by range-diff, both changed file hashes and all 30 inspected owner/caller/test/doc contexts are unchanged. The 34-test source proof is reused; unrelated main package/script changes are covered by fresh exact-head hosted CI and native gates, not claimed as an identical installation. Previous failed CI and historical timing remain retained.Exact refreshed head
9f8b7c1993406d81d75b915e5658602f7f82f100passed CI run 34773626068, including the aggregate gate, production/test typing, lint and applicable tests. The current-head hosted source review reports no actionable findings. All four normal native source stages verified the same two changed file bytes and 30 inspected contexts; captured main21de1eaf75db7f80cbc3114a451db244c07d9267still lacks this batch wrapper.