Skip to content

fix(memory): keep managed local-service readiness on its own budget during memory_search - #143590

Merged
obviyus merged 3 commits into
openclaw:mainfrom
wangmiao0668000666:fix/memory-search-local-service-cold-start
Sep 10, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
wangmiao0668000666:fix/memory-search-local-service-cold-start

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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_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.

…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]>
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: memory-core Extension: memory-core triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: L and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 10, 2026
@obviyus obviyus self-assigned this Sep 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 1:38 AM ET / 05:38 UTC (Revision 3).

ClawSweeper review

What this changes

Separates 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
Reviewed head: 0c8431869ad10d86f87594c41d6ab92a697ec9a9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with relevant production-path observations and regression coverage; no blocking correctness or security finding remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied built-Gateway observations exercise registered memory_search, real SQLite storage, and a managed HTTP embedding child through the changed production owners, showing successful 70-second readiness, semantic recall, warm retry, independent wiki timeout, and bounded post-readiness work.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied built-Gateway observations exercise registered memory_search, real SQLite storage, and a managed HTTP embedding child through the changed production owners, showing successful 70-second readiness, semantic recall, warm retry, independent wiki timeout, and bounded post-readiness work.
Evidence reviewed 10 items Current main still has the reported deadline conflict: The fetched main revision arms an unconditional corpus timer and forwards the embedding signal into local-service acquisition. It has no readiness pause channel.
Latest release retains the fixed corpus timer: Inspection of the supplied latest release, v2026.9.3, also shows the unconditional corpus deadline; this repair is not established as shipped.
Readiness ends before reconciliation: Acquisition reports readiness completion in finally; ensureProviderLocalService subsequently performs reconciliation. The provider forwards the per-call control without changing endpoint validation, request credentials, or lease ownership. This is OpenClaw's own embedding/service implementation and supplies no Codex dependency signal.
Findings None None.
Security None None.

How this fits together

Memory 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
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +214, Tests +443, Docs +2. Total +659 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 14 284 70 +214
Tests 8 448 5 +443
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 734 75 +659

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +211 lines; tests and test support net +446 lines Production growth carries one request-local timing contract across two deadline owners and the readiness owner; the added coverage protects those distinct boundaries.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/memory-corpus.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-embedding-ops.ts, unknown-data-model-change: extensions/memory-core/src/tools.ts, unknown-data-model-change: packages/memory-host-sdk/src/host/search-deadline-control.ts, unknown-data-model-change: src/plugins/openai-compatible-embedding-provider.ts, vector/embedding metadata: extensions/memory-core/src/memory-corpus.ts, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #143169
Summary: This PR is one of three unmerged candidates for the same managed-embedding cold-start deadline conflict.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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.

Labels

Label justifications:

  • P2: The fix restores semantic recall for managed local embedding services whose healthy cold starts exceed the normal search budget.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied built-Gateway observations exercise registered memory_search, real SQLite storage, and a managed HTTP embedding child through the changed production owners, showing successful 70-second readiness, semantic recall, warm retry, independent wiki timeout, and bounded post-readiness work.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied built-Gateway observations exercise registered memory_search, real SQLite storage, and a managed HTTP embedding child through the changed production owners, showing successful 70-second readiness, semantic recall, warm retry, independent wiki timeout, and bounded post-readiness work.

Evidence

What I checked:

  • Current main still has the reported deadline conflict: The fetched main revision arms an unconditional corpus timer and forwards the embedding signal into local-service acquisition. It has no readiness pause channel. (extensions/memory-core/src/memory-corpus.ts:107, 0153d84c02af)
  • Latest release retains the fixed corpus timer: Inspection of the supplied latest release, v2026.9.3, also shows the unconditional corpus deadline; this repair is not established as shipped. (extensions/memory-core/src/memory-corpus.ts:110, 1391f7cd2d40)
  • Readiness ends before reconciliation: Acquisition reports readiness completion in finally; ensureProviderLocalService subsequently performs reconciliation. The provider forwards the per-call control without changing endpoint validation, request credentials, or lease ownership. This is OpenClaw's own embedding/service implementation and supplies no Codex dependency signal. (src/agents/provider-local-service.ts:137, 0c8431869ad1)
  • Independent wiki cancellation and preserved results: The wiki deadline now follows callerSignal directly. Supplement timeout is converted into a corpus outcome, allowing completed primary results to survive aggregation without starting a primary-memory cooldown. The GitHub commit endpoint confirms this parentSignal correction is the latest production change. (extensions/memory-core/src/tools.ts:426, 0c8431869ad1)
  • Prior packaged-consumer concern reassessed: The control export's entrypoint is explicitly private-local-only. SDK packaging retains its JavaScript runtime for official plugins while excluding public declarations; the memory-host-sdk package is private. Existing embedding and manager call fields remain optional. A separately installed third-party consumer is therefore not required to establish this narrow repair's compatibility. (scripts/lib/plugin-sdk-private-local-only-subpaths.json:85, 0c8431869ad1)
  • After-fix production-path evidence: The complete supplied PR body, captured under sourceRevision ef3808a21bbd6121835443c3072aff2eb43be445109b4a85bd250ef55e1e8120, describes a built isolated Gateway invoking registered memory_search against real Memory Core SQLite and a managed child HTTP embedding service. It reports baseline failure during a 70-second cold start, candidate semantic recall and warm retry, fast/slow wiki outcomes, cancellation controls, readiness failure, bounded embedding HTTP work, and reconciliation timeout before query I/O. The final rebuilt flow reports retained memory results and a 107 ms retry. These are supplied observations, not executions by this reviewer. (0c8431869ad1)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-10T02:04:36.775Z sha c4d4c3d :: blocked before merge. :: [P2] [P2] Give wiki supplements an independent deadline | [P2] [P2] Resume the budgets before managed-router reconciliation
  • reviewed 2026-09-10T03:26:03.254Z sha 7d69c99 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes agents Agent runtime and tooling extensions: codex size: XL triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: L labels Sep 10, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed cli CLI command changes extensions: codex size: XL labels Sep 10, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 10, 2026
@obviyus
obviyus merged commit 874b2ce into openclaw:main Sep 10, 2026
222 of 225 checks passed
@obviyus

obviyus commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666!

Proof: A built Gateway used the registered memory_search tool, real Memory Core storage, and a managed child service with synthetic loopback providers.

  • Bug: The search deadline stopped valid cold starts and lost semantic recall.
  • Fix: Readiness uses its own budget; wiki, reconciliation, and embedding requests retain their bounds. A wiki timeout preserves completed memory results and permits an immediate retry.
Before After
A 70-second startup was stopped at 15 seconds. Startup completes and returns the semantic memory hit.
A stalled wiki could hide available memory and trigger cooldown. Memory remains available; the next search completed in 107 ms.

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.

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

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.

@wangmiao0668000666
wangmiao0668000666 deleted the fix/memory-search-local-service-cold-start branch September 10, 2026 05:53
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…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]>
Orionation pushed a commit to Orionation/openclaw-1 that referenced this pull request Sep 23, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: memory-core Extension: memory-core gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory_search aborts managed local embedding cold start before ready timeout

2 participants