Repository navigation
improve: reduce chat metadata refresh work - #147137
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, 12:49 PM ET / 16:49 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR reuses agent-roster lookups during synchronous chat metadata capture and adds regression coverage for refresh cost, owner replacement, and roster changes. Merge readiness✅ Ready for maintainer review This remains a useful, focused performance improvement absent from current main. No actionable correctness or security findings remain; the protected maintainer PR should proceed through ordinary review. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway prepares chat metadata from configured agents and their published model catalogs. Its refresh lifecycle supplies coherent model and command information to chat readers while tracking configuration, authentication, and skill changes. flowchart TD
A[Configured agents] --> B[Synchronous roster batch]
C[Published model catalogs] --> B
B --> D[Capture metadata facts]
D --> E{Generation changed?}
E -->|No| F[Reuse prepared metadata]
E -->|Yes| G[Build and verify replacement]
G --> H[Chat metadata readers]
F --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +197. Total +200 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep roster reuse confined to each synchronous capture while preserving published-owner selection and fresh generation checks after asynchronous preparation. Do we have a high-confidence way to reproduce the issue? Yes: current source repeats roster resolution through published-owner input preparation, and the added 64-agent cases target that cost directly. This review inspected the path without executing it. Is this the best way to solve the issue? Yes: using the existing exact-config synchronous batch is a narrow solution that avoids a new cache or invalidation policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4b2b59362dec. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
6bc4ab6 to
1b45404
Compare
|
Merged via squash.
|
Related: #145679
What Problem This Solves
Chat metadata refreshes repeat agent-roster resolution while reading the already-published model owners for each configured agent.
Why This Change Was Made
Run the synchronous generation-fact capture inside the existing roster-facts batch. The batch ends with that capture; the next capture reads fresh configuration. Published-owner lookup, admission, auth/skills generations, and asynchronous generation checks retain their existing owners.
User Impact
Reduces work during prepared chat metadata refreshes for larger keyed agent rosters. In the fixed synthetic 64-agent keyed-roster comparison, mean elapsed time fell 27.25% and CPU time fell 21.83%. The list-roster result was mixed, including one slower candidate pair; this is not a claim of consistent improvement for every roster shape or of Gateway-wide throughput, cold startup, or sustained idle performance.
Evidence
Raw fixed timing and qualifications
Each cell contains 16 refresh calls. Elapsed/CPU are milliseconds for the whole cell; CPU includes process user and system time. Columns retain execution order.
For 64 keyed agents, both elapsed/CPU pairs improved (mean elapsed 69.510 to 50.571 ms; mean CPU 84.721 to 66.227 ms). For 64 list agents, the mean improved 8.52% elapsed and 4.80% CPU, but O2/C2 regressed from 50.150 to 58.237 ms and from 92.089 to 102.984 ms. The second singleton-list pair was also adverse. Two observations per variant do not establish statistical significance.
Native process peak RSS in O1/C1/C2/O2 order was 2790.30 / 2765.13 / 2786.06 / 2751.53 MiB. Those GNU-time peaks cover the full test invocation and setup; they are not summed concurrent process-tree RSS. The worker RSS before/after each cell and worker lifetime peaks are retained separately. Neither is a window-only allocation measurement or evidence of a memory improvement.
The timed boundary excludes imports, initial publication, and initial generation. Real published-owner fallback scans remain in the measured path. Instrumented work counts are separate from timing. Stateful roster getters can observe fewer reads within the synchronous batch; fresh facts are not retained across captures.
Source/behavior/timing proof uses frozen
c1191cf5c9b29f617b765216b16ffa992a8bef09plus this candidate. All 34 reviewed source contexts and the three publication-policy files are unchanged at refreshed main8baed117f6d9aa4172e6bd71fb7d18d88c81b1b5; the new test is absent on both bases. Exact-head hosted integration passed. Later main commit05177019separates runtime default designation from legacy data ownership; source inspection confirmed that the existing exact-config synchronous batch lifetime and published-owner lookup remain intact. The historical measurements do not quantify that newer main policy. No local full build is claimed for this existing synchronous import and unchanged API contract.