Repository navigation
fix(memory): keep managed local-service readiness on its own budget during memory_search - #143590
Conversation
…uring memory_search A managed local embedding service owns its startup through localService.readyTimeoutMs (default 120s), but memory_search wrapped the whole tool in a fixed 15s deadline whose signal flowed into acquireLocalService. Any cold start longer than 15s was aborted mid-startup, the search returned 'memory_search timed out after 15s', and the killed startup made every retry start cold again. Reintroduce the owner-boundary control channel known from the QMD era as a shared symbol-keyed per-call contract (packages/memory-host-sdk host/search-deadline-control): the OpenAI-compatible embedding provider reports an owned phase around managed acquisition only, and both enclosing budgets - the corpus deadline and the per-query embedding watchdog - bank their remaining time while the phase runs. Manager setup, retrieval, supplements, and cleanup keep the existing 15s budget; caller cancellation stays on the AbortSignal and aborts acquisition immediately. Fixes openclaw#143169 Co-Authored-By: Claude <[email protected]>
|
🦞👀 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: blocked before merge. Reviewed September 10, 2026, 1:38 AM ET / 05:38 UTC (Revision 3). ClawSweeper reviewWhat this changesSeparates managed embedding-service startup from memory-search time budgets while preserving caller cancellation, bounded retrieval, and independent wiki deadlines. Merge readiness⛔ Blocked before merge - 1 item remains The repair remains necessary on current main and addresses the earlier deadline findings. No blocking defect was found; the previous third-party SDK proof request does not fit the private host-runtime export involved. Priority: P2 Review scores
Verification
How this fits togetherMemory Core turns search queries into embeddings and retrieves matching stored memories. When its embedding server is managed locally, the service owner starts that server and waits for readiness before sending the embedding request. flowchart TD
A[Memory search query] --> B[Memory search budget]
B --> C[Managed service readiness]
C --> D[Embedding request and retrieval]
D --> F[Combined search results]
A --> E[Independent wiki budget]
E --> F
G[Caller cancellation] --> B
G --> E
Before merge
Agent review detailsSecurityNone. PR surfaceSource +214, Tests +443, Docs +2. Total +659 across 23 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: 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 readiness timing with the managed-service owner and preserve independently bounded search work through the existing private host-runtime seam. Do we have a high-confidence way to reproduce the issue? Yes, from current source: invoke memory_search against a cold managed embedding service whose readiness takes more than 15 seconds but remains within readyTimeoutMs. The unchanged outer deadline aborts acquisition; this review did not execute that scenario. Is this the best way to solve the issue? Yes. Reporting readiness at its lifecycle owner covers both enclosing clocks without increasing unrelated timeouts, changing manager identity, or introducing configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0153d84c02af. 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) |
|
Thanks @wangmiao0668000666! Proof: A built Gateway used the registered
Validation: 120 focused memory tests, retained provider/lifecycle controls, fresh exact-head review, and the complete GitHub CI run passed. Both previously failing CI jobs are green. The automated migration reminder does not apply: this change adds only per-call timing state and changes no stored schema or data format. The deadline-control export is a private host interface, so the earlier third-party SDK suggestion is not a public compatibility requirement. |
|
Thank you @obviyus — both for the thorough review and for carrying this over the finish line. Your merge-commit rework taught me a couple of things I'll keep for future contributions: the way you ran the reconciliation-boundary control (100ms vs 25s reconcile after a 70s cold start) to pin the budget ownership semantics, and validating against a real built Gateway rather than stopping at focused tests. Seeing the findings land with that level of proof set a much higher bar than my original submission. Appreciate you preserving the original commit in the history as well. Glad the cold-start path is fixed. |
…ss (openclaw#143590) Fixes openclaw#143169. Managed embedding cold starts could exceed the 15-second memory-search limit even while inside the configured readiness timeout. The search then aborted startup and lost semantic recall. This change pauses the corpus and query-embedding clocks only while the service owner waits for readiness. Each clock resumes with its remaining budget before router reconciliation or embedding HTTP work. Concurrent wiki searches keep a separate 15-second deadline. A wiki timeout preserves completed memory results and leaves memory retries available. Caller cancellation, shared service leases, readiness failure, and idle shutdown retain their existing owners. The repair also handles a query watchdog that subscribes during an existing pause and removes the corpus listener when work ends. No new configuration, database schema, persistence policy, or dependency is introduced. Validation uses an isolated built Gateway, the registered `memory_search` tool, real Memory Core SQLite storage, a synthetic loopback chat endpoint, and a managed child embedding service. The baseline aborts a 70-second cold start at the search deadline. The corrected candidate returns the known semantic hit after readiness; its warm retry works. Slow wiki results are excluded and fast wiki results are retained. Persistent public-client controls cover shared and solo cancellation, the configured readiness failure, and an embedding HTTP request that exceeds the remaining search budget. A separate registered-adapter control confirms that 100 ms reconciliation after a 70-second startup preserves recall, while 25-second reconciliation is aborted at about 15 seconds before any query embedding request. After the final CI correction, 120 focused memory tests passed, including the stalled-wiki result and retry regression. A rebuilt public flow preserved memory at the wiki timeout and completed the next memory search in 107 ms. Earlier provider, service, and deadline-control tests remain applicable to their unchanged owners. Original-code probes fail at the repaired boundaries. Formatting, ordinary lint, source ratchets, the native commit hook, and the runtime build passed. Full type checking and broader suites run in GitHub CI. The loopback fixtures use deterministic embeddings; they do not certify an external provider or arbitrary model quality. Co-authored-by: Ayaan Zaidi <[email protected]>
…M Studio embedding providers memory_search has a managed readiness budget that pauses the search deadline while a local service starts up (via onReadinessWait callbacks on the localServiceTarget). PR openclaw#143590 wired this up for the OpenAI-compatible embedding provider, but the Ollama and LM Studio adapters never forwarded the callback, so a cold-start acquisition on those providers still consumed the full search deadline. Both providers now extract MemorySearchDeadlineControl from callOptions via MEMORY_SEARCH_DEADLINE_CONTROL and pass an onReadinessWait callback into acquireLocalService, matching the existing pattern in openai-compatible-embedding-provider.ts. - Ollama: onReadinessWait forwarded from embed/embedBatch callOptions through embedMany/embedOne to the acquireLocalService call - LM Studio: onReadinessWait forwarded through withLocalServiceLease, used by both embed and embedBatch (non-query path) Query embedBatch delegates to embed and inherits its own lease per query, so no additional change is needed there. Fixes openclaw#156359
Fixes #143169.
Managed embedding cold starts could exceed the 15-second memory-search limit even while inside the configured readiness timeout. The search then aborted startup and lost semantic recall.
This change pauses the corpus and query-embedding clocks only while the service owner waits for readiness. Each clock resumes with its remaining budget before router reconciliation or embedding HTTP work. Concurrent wiki searches keep a separate 15-second deadline. A wiki timeout preserves completed memory results and leaves memory retries available. Caller cancellation, shared service leases, readiness failure, and idle shutdown retain their existing owners.
The repair also handles a query watchdog that subscribes during an existing pause and removes the corpus listener when work ends. No new configuration, database schema, persistence policy, or dependency is introduced.
Validation uses an isolated built Gateway, the registered
memory_searchtool, real Memory Core SQLite storage, a synthetic loopback chat endpoint, and a managed child embedding service. The baseline aborts a 70-second cold start at the search deadline. The corrected candidate returns the known semantic hit after readiness; its warm retry works. Slow wiki results are excluded and fast wiki results are retained. Persistent public-client controls cover shared and solo cancellation, the configured readiness failure, and an embedding HTTP request that exceeds the remaining search budget.A separate registered-adapter control confirms that 100 ms reconciliation after a 70-second startup preserves recall, while 25-second reconciliation is aborted at about 15 seconds before any query embedding request.
After the final CI correction, 120 focused memory tests passed, including the stalled-wiki result and retry regression. A rebuilt public flow preserved memory at the wiki timeout and completed the next memory search in 107 ms. Earlier provider, service, and deadline-control tests remain applicable to their unchanged owners. Original-code probes fail at the repaired boundaries. Formatting, ordinary lint, source ratchets, the native commit hook, and the runtime build passed. Full type checking and broader suites run in GitHub CI. The loopback fixtures use deterministic embeddings; they do not certify an external provider or arbitrary model quality.