Repository navigation
fix: release retired session metadata after short listings - #136567
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 4:04 PM ET / 20:04 UTC. ClawSweeper reviewWhat this changesThe PR removes a cross-request cache that strongly retained session entries after short Gateway session listings and adds a garbage-collection regression test. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR open: the current main branch still retains full session snapshots through the short-list candidate cache, while the proposed request-local index removes that ownership without changing child-link resolution. No blocking correctness or security defect was found in the introduced patch. Priority: P2 Review scores
Verification
How this fits togetherGateway session listing loads a combined snapshot of agent session stores, derives child-session links, and returns lightweight rows to RPC clients, the TUI, and startup prewarm. This change removes a process-level derived cache between the fresh snapshot and that row projection. flowchart LR
A[Agent session stores] --> B[Combined session snapshot]
B --> C[Gateway session listing]
C --> D[Request-local child link index]
D --> E[Lightweight session rows]
E --> F[RPC clients and startup prewarm]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -66, Tests +50. Total -16 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Merge the request-local child-link index and retain the isolated GC regression so short listings cannot pin obsolete combined-store metadata. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible with high confidence: current main stores every short-list snapshot entry in a process-level Map, while the added isolated GC test directly exercises the list projection and would retain those entries on the baseline. Is this the best way to solve the issue? Yes. The cache belongs to a derived, fresh combined-store projection and cannot safely provide useful cross-request identity reuse there; deleting it and retaining only selected request-local links is the narrowest owner-boundary repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0ad459206e68. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Resolves unnecessary memory retention after short session listings. Large metadata from a completed listing could remain alive until another request replaced the cached store, or the bounded cache evicted it.
Why This Change Was Made
The child-session candidate cache held every
SessionEntrystrongly to compare identities. Gateway RPC, embedded TUI, embedded tools, and startup prewarm all construct fresh combined entries, so those requests paid for a cache miss while retaining the preceding snapshot.Remove that cache and its identity comparison, and use the existing request-local index for the selected parents. Live-controller, navigation-lineage, visibility, ordering, and freshness checks remain in their existing owner. A weak-reference cache would retain the redundant lookup path without useful cross-request hits.
Production: +6/-72 (net -66). Tests/test support: +79/-29 (net +50). The removed test asserted reuse of the retired cache; the replacement checks collection through the real list projection while preserving its returned child links. No schema, persistence, configuration, dependency-version, or public protocol change.
User Impact
Retired listing snapshots are no longer pinned by this derived cache. This is bounded over-retention, not a demonstrated unbounded leak. It does not establish that the separate event-loop saturation issue is solved.
Evidence
aef65cc57490a5c67ca8dc934ac24225c6d1069c.sourcePerformancebuild succeeds. Independent managed Codex review is clean through P2.{ limit: 1 }(plus import relocation), to exercise this path.Hosted CI: run 33676308549, attempt 2 passed on
321642251c725df0ce80d179f3ad3be71fae7b1a. The first attempt had 155 successful jobs and one cancellation before any step executed; one normal retry targeted that job, without changing source. The required CI gate is now green.