Repository navigation
fix: agent session searches stall on large histories - #200355
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper review Please review the bounded agent recall path at head 36c35fc, particularly visibility before limits, physical global-session ownership, shared logical-agent stores, and exact CJK timestamp ordering. The accepted CJK contract is one complete streaming text pass on hits and misses with bounded top-N memory; timestamps are unindexed and there is no schema change. Codex autoreview and focused authorization, no-paging, UI browser and real-Gateway UI-e2e tests passed. |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36c35fc80b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. What this changesThis PR replaces session-inventory paging with transcript-first search and bounded visibility filtering. Example: An agent searches the supplied 17,000-session synthetic history.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a remaining broad-search bottleneck, both previous findings are fixed, and no new actionable code defect was established. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe agent search tool calls the Gateway, which searches existing transcript indexes in workers and authorizes matching session keys before returning bounded excerpts. flowchart LR
A[Agent search tool] --> B[Gateway recall handler]
B --> C[Admitted store topology]
C --> D[Transcript worker]
D --> E[Gateway visibility owner]
E --> D
D --> F[Bounded search results]
Technical reviewBest possible solution: Keep transcript discovery in the existing worker and visibility decisions in the existing Gateway owners, using admitted topology and bounded candidate batches. Do we have a high-confidence way to reproduce the issue? Current main visibly enumerates the session inventory before broad searches, and the supplied baseline measurements exercise that path; no target code was executed during this read-only review. Is this the best way to solve the issue? The implementation removes the demonstrated inventory cost, shares recall between embedded and RPC callers, and preserves explicit-session search without adding persistent state or a cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b4fc05346afb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +298, Tests -145, Docs +2, Other +12. Total +167 across 34 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 16, 2026, 10:12 PM ET / November 17, 2026, 03:12 UTC (Revision 2). |
|
Addressing both open items from the latest review on final head
Validation: the repaired consumer run passed 62 tests; the final topology run passed 36 Gateway/embedded-tool tests; the selection consumer and selection suite passed 6 and 8 tests. Core, core-test shards and scripts typechecks pass. Fresh Codex autoreview is clean. The final 17,000-session word/CJK measurements are 26.9/68.4 ms, with unchanged result digests and zero inventory pages. Affected UI browser and real-Gateway UI-e2e tests pass. This is real tool/embedded Gateway/native-worker proof plus Gateway UI-e2e; it is not a real-model search roundtrip. The PR body records that limit and exact-parent inherited failures. The final complete changed-check and hosted CI runs are pending. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32a654caea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| sessionMutationAuthorization?.assertCurrent(); | ||
| respond(true, result); |
There was a problem hiding this comment.
Reauthorize recall results at response publication
If a session becomes private or the viewer loses access after its candidate batch is authorized—for example, while recall searches a later agent store—the previously accepted excerpts are still returned here. searchRecallSessionTranscripts checks sharing inside worker callbacks, then retains those hits across subsequent awaits without validating them again; sessionMutationAuthorization?.assertCurrent() does not recheck each hit's sharing policy. Unlike the existing scoped search path, this can disclose transcript text after access has been revoked. Reacquire current visibility for the retained results and associated counts, retrying or discarding changed pages, and publish within the synchronous authorization frame required by the Gateway guidance.
AGENTS.md reference: src/gateway/AGENTS.md:L54-L54
Useful? React with 👍 / 👎.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* fix: agent session searches stall on large histories * fix: preserve pinned session recall visibility * fix(sessions): reuse admitted search store topology
Search transcript indexes before authorizing bounded batches of matching keys instead of paging the full session inventory. Keep current and pinned tool visibility checks, scoped searches, and existing literal FTS behavior. Adapted for the 2026.11.6 owners without the unrelated CJK substring or async execution-capture migrations. Regenerate Gateway validators canonically. Backport-of: a564030 Co-authored-by: RomneyDa <[email protected]>
* fix: agent session searches stall on large histories * fix: preserve pinned session recall visibility * fix(sessions): reuse admitted search store topology (cherry picked from commit a564030) Release adaptation: Retain baseline deletion of retired session-identity allowlist.: Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit e485cc01271ce5f0ad0c2ed5c4a5b8003654d37b)
What Problem This Solves
Fixes: agent session searches stall on large histories because every query first pages through the complete session inventory.
User Impact
Agents can search existing conversation text without listing every session first, with the same bounded result shape and visibility rules. No configuration, schema, index, or migration changes are required.
Short CJK substring searches retain their documented behavior. Because timestamps are not indexed, that fallback completes one streaming text pass even after finding matches, retaining only the best
limit + 1hits and one bounded authorization batch. A miss can still scan the text corpus.Why This Change Was Made
The transcript worker now discovers candidates using the existing word FTS index; Gateway visibility owners authorize bounded candidate batches before result limits, applying both current Gateway rules and the tool’s captured restrictions. The tool's inventory paging and per-agent 200-key RPC loops are removed. The embedded Gateway and RPC handler share this owner, while explicit-session search keeps its existing path. Broad search reuses the projection’s admitted store topology instead of rediscovering filesystem stores on each request; configured logical agents still retain their shared-store mapping.
The simplification removes a single-use request adapter and duplicate ordering/visibility plumbing. Production delta is +298 lines total: +253 authored and +45 generated predicates; authored code is reduced from the earlier +261 proposal, and tests remove 145 net lines. The initial simplification removed 45 authored lines; preserving the pre-existing pinned caller-policy boundary adds 37 back. Admitted-topology reuse removes three more runtime lines, and keeping its store targets out of the row-selection input contract adds three type-only lines. The remaining growth implements the bounded worker cursor and Gateway authorization boundary that replace 85 inventory pages plus 90 search RPCs per search on the synthetic fixture. No new cache or session-row projection optimization is included.
Integration note: #200076 adds a cold-archive exclusion predicate to the same query kernel. This change moves that kernel from
session-transcript-search.tstosession-transcript-search.worker.ts; preserve that predicate there when integrating whichever PR lands second. #160237 shares the scope test file but changes the separate UI search path.Evidence
The 17,000-session synthetic fixture uses 8 agents, 13,700 archived metadata rows, 30 active runs, and one indexed message per session. It contains no production data. Two baseline controls and candidate runs use 2 warmups and 5 measured searches, with timing and sampled main-thread JS allocation measured separately.
Both candidate paths use 0 inventory pages / 0 inventory rows / 1 search RPC, versus 85 / 17,000 / 90. Final p95 is 29.5 ms (word) and 73.2 ms (CJK). This was a busy shared host; no quiet-host claim. Measurements exercise the real tool, embedded Gateway and native worker, not a remote model round-trip. The fixture represents session cardinality, not a 35-GiB database or a filesystem-scale workload.
Complete top-N result digests match baseline and candidate, including snippets and flags:
378af0fc548a5b970756d143775fbf73a7cd00757250ade78ed5e305f16eca9bbe44535ac95c4887e43eaf52c811c8efdf61821a7d3868f8c330f816f44523752475ff7a16b61ce3a7675cb156dfa84cf306b4529ebcf5d48832c89f30ce1cbd753826edc7256a0e891a56ed820740d2682753e75128c7e72988ec7949b25ee9Focused tool/protocol/native-search/Gateway tests pass, including no inventory paging, cross-agent and operator privacy, sandbox/tree boundaries, shared stores, and a CJK match at the end of the text rows that must enter the timestamp-ordered top-N. The no-paging regression fails on the exact parent. The final topology rerun passes 36 Gateway/embedded tests; the selection fixture consumer passes 6 tests and the updated selection suite passes 8. The 15 prompt-stability tests, affected UI browser test, and real-Gateway UI-e2e test pass. Codex autoreview reports no actionable P0–P2 findings.
The final-head
pnpm check:changedrun passes every gate except the inherited dead-export check, including all typecheck, format, lint and database-worker guards. The dead-export gate has 116 unique findings, all reproduced among 121 findings on exact parentaeabca2e109167fe9dbc0037fd698848a2378b63; no new dead-export findings. Three replay-session-state re-exports are attributable to472cd0a2f542599eea763f013eba2d34033ca25f; the remaining entries have exact-parent reproduction without individual introduction attribution. These are inherited main regressions, not passing checks. CI exposed two stale inventory-shaped consumer suites. Converting the visibility fixture to real indexed search also exposed a lost pinned caller-policy restriction; that regression fails on the first PR head with a foreign hit and now passes. The repaired 62-test focused run, affected UI browser and real-Gateway UI-e2e tests, and fresh Codex review pass. CI also required the static identity-pin allowance to shrink 12→8; the canonical generator lowers that single entry. No runtime configuration changed. Final-head CI run 44006736986 has the heartbeat build-test timeout described below; ClawSweeper revision 2 reviewed final head32a654caeaad813b75c5f8a1be703085eed7aeddwith zero open items (review); both prior items are addressed in the numbered response.A previous-head CI build-graph timeout also reproduces on exact parent
aeabca2e109167fe9dbc0037fd698848a2378b63: the state lease heartbeat optional-import test reaches its 60-second timeout. The 60-second heartbeat build test originated in #191272 (c3b3d56c37c90), and #198194 generalized it; the exact source of build-time variance remains unproven. The same parent also fails the transcript-worker graph guard (623 forbidden Gateway inputs); this branch has the same existing import path plus the new recall module. These are recorded main regressions, not passing proof. Final hosted CI evaluates the current merge context.On the exact CI parent
f57dbb4ff67efb110bed6568f49ea008bc43c4a2, the full build-graph file passes under the local default runtime, and the isolated heartbeat case passes under both default and Bun runtimes. The isolated case also passes on tested merge7fe920ad2bf412ff9100e77aa135035678dc548c. These passing replays are not a fix. Independent attribution now also compares the complete heartbeat dependency closure: all 559 source inputs, plus the test and build configuration, are identical between that CI parent and tested merge. Together with the exact original-parent timeout reproduction, this qualifies the authorized inherited-only landing exception. The automated CI table remainsunknownbecause its scheduled-main comparison did not execute this heartbeat case. The timeout is an inherited main regression requiring follow-up, and failed hosted CI is not reported as green.