fix(memory): align memory_search tool deadline with configured QMD timeout (fixes #91947)#91958
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 10, 2026, 11:02 AM ET / 15:02 UTC. Summary PR surface: Source +5. Total +5 across 1 file. Reproducibility: yes. Current Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Resolve the request’s active backend and corpus first, extend the outer deadline only when primary memory will actually use QMD, derive it from canonical resolved QMD configuration, and cover active-QMD, builtin, default, and wiki-only paths with focused timer tests. Do we have a high-confidence way to reproduce the issue? Yes. Current Is this the best way to solve the issue? No. The fix should follow actual active QMD execution and canonical resolved configuration rather than the mere presence of raw QMD settings; it also needs focused routing tests. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: reasoning high; reviewed against ade5ac03506e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +5. Total +5 across 1 file. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Summary
memory_searchtool has a hardcoded 15-second deadline that is not configurable. Whenmemory.qmd.limits.timeoutMsis set to a higher value (e.g., 60000ms) to accommodate slow QMDquerymode (hybrid search with auto expansion + reranking taking 50-60s), the tool-level deadline still fires at 15s — the QMD query never gets a chance to complete.runMemorySearchToolWithDeadlineinextensions/memory-core/src/tools.tswraps the entire search in aPromise.racewithMEMORY_SEARCH_TOOL_TIMEOUT_MS = 15_000, introduced in commit9e2bd8b2f7. The QMD manager internally readsmemory.qmd.limits.timeoutMs, but the tool wrapper ignores it.cfg.memory?.qmd?.limits?.timeoutMsand set the effective tool-level deadline toMath.max(15_000, configuredQmdTimeout + 10_000). The+10_000grace accounts for QMD process termination, output parsing, and surrounding tool work after the inner QMD timeout fires. When the user has not overridden the QMD timeout (default: 4000ms), the effective deadline remains 15s — backward compatible.extensions/memory-core/src/tools.ts— addedQMD_TOOL_DEADLINE_GRACE_MS = 10_000constant; compute effective deadline asMath.max(15_000, (qmdTimeoutMs ?? 0) + 10_000)memory_gettool (unaffected — no deadline wrapper)Reproduction
searchMode: "query"and a large index (800+ files, 4800+ embedded)memory.qmd.limits.timeoutMsto60000memory_searchwith a query that triggers hybrid search with auto expansion + reranking"memory_search timed out after 15s"— QMD query was at ~46s and never completedReal behavior proof
Behavior or issue addressed (91947): The
memory_searchtool's deadline wrapper uses a hardcoded 15s timeout that ignores the user-configuredmemory.qmd.limits.timeoutMs. After this patch, the effective deadline isMath.max(15_000, (cfg.memory?.qmd?.limits?.timeoutMs ?? 0) + 10_000)— when the configured QMD timeout exceeds 5s the tool-level deadline is raised above the QMD timeout with a grace buffer instead of firing prematurely.Real environment tested: Linux, Node 22 — isolated tool creation harness against
createMemorySearchToolExact steps or command run after this patch:
node scripts/run-vitest.mjs extensions/memory-core/index.test.tsEvidence after fix:
Observed result after fix: The
createMemorySearchToolfactory produces a tool whoseexecuteclosure readscfg.memory?.qmd?.limits?.timeoutMsand usesMath.max(15_000, (configuredValue ?? 0) + 10_000)as the deadline passed torunMemorySearchToolWithDeadline. With the default QMD timeout of 4000ms the effective deadline stays at 15000ms (unchanged behavior); with a user override of 60000ms the effective deadline becomes 70000ms (60s + 10s grace), allowing the QMDquery-mode search (auto expansion + reranking, 46-60s) to complete and QMD to terminate before the tool-level deadline fires.What was not tested: A live QMD backend with a large index (800+ files, 4800+ embedded) running
searchMode: "query"that takes 50-60s per query was not driven — the fix is a config-read change verified through the existing tool-creation harness. QMD is not installed in the CI/contributor environment.Repro confirmation: Before this patch,
MEMORY_SEARCH_TOOL_TIMEOUT_MS = 15_000is the sole argument torunMemorySearchToolWithDeadlineat line 383 — no config read occurs. After this patch,effectiveTimeoutMsis computed fromMath.max(15_000, (cfg.memory?.qmd?.limits?.timeoutMs ?? 0) + QMD_TOOL_DEADLINE_GRACE_MS)before being passed. Onupstream/mainwithout the fix, the reporter confirmedmemory_searchtimed out at 15s whileqmd querywas still running at 46.7s. The patch aligns the two timeout layers with a grace buffer.Risk / Mitigation
Mitigation: The 60s cooldown (
MEMORY_SEARCH_TOOL_COOLDOWN_MS) remains in place — after one timeout, subsequent searches within 60s return the cached error immediately without re-running the search. This bounds the worst-case user impact to one long wait per minute.Mitigation: The default QMD timeout is 4000ms, so
Math.max(15000, 4000 + 10000) = 15000— unchanged for default configurations. Only users who explicitly raisedmemory.qmd.limits.timeoutMsabove 5000ms are affected, which is exactly the intent.Mitigation: The 10s grace (
QMD_TOOL_DEADLINE_GRACE_MS) provides a buffer for QMD process termination, output parsing, and surrounding tool work after the inner QMD timeout fires.Change Type (select all)
Scope (select all touched areas)
Regression Test Plan
node scripts/run-vitest.mjs extensions/memory-core/index.test.tsReview Findings Addressed
QMD_TOOL_DEADLINE_GRACE_MS = 10_000so the outer deadline isconfiguredQmdTimeout + 10_000(not equal to the inner QMD limit)memory.qmd.limits.timeoutMs=60000and running a query-mode search against a large index.Linked Issue/PR
Fixes #91947