Skip to content

fix(memory): forward deadline control onReadinessWait to Ollama and LM Studio embedding providers - #156434

Closed
Orionation wants to merge 5 commits into
openclaw:mainfrom
Orionation:fix/ollama-lmstudio-embedding-readiness
Closed

Orionation wants to merge 5 commits into
openclaw:mainfrom
Orionation:fix/ollama-lmstudio-embedding-readiness

Conversation

@Orionation

@Orionation Orionation commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

memory_search pauses its deadline timer during managed local service startup via onReadinessWait callbacks on the localServiceTarget. PR #143590 wired this up for the OpenAI-compatible embedding provider, but the Ollama and LM Studio adapters did not forward the callback, causing premature search cancellation on cold starts.

Fix

Both providers now extract MemorySearchDeadlineControl from callOptions via MEMORY_SEARCH_DEADLINE_CONTROL and pass an onReadinessWait callback into acquireLocalService.

Type fix (addressing ClawSweeper review)

The MemoryCoreAcquireLocalService target type in both adapters was missing the onReadinessWait field, producing an excess-property TypeScript error. Fixed by adding the optional callback to the locally-defined MemoryCoreAcquireLocalService target type in both files:

type MemoryCoreAcquireLocalService = (
  target: {
    providerId: string;
    baseUrl: string;
    headers?: HeadersInit;
    /** Pause/resume the managed-readiness search deadline during local service startup. */
    onReadinessWait?: (waiting: boolean) => void;
  },
  signal?: AbortSignal | null,
) => Promise<{ release: () => void } | undefined>;
  • 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 the non-query embedBatch path

Evidence

  • Existing onReadinessWait integration test coverage in the OpenAI-compatible adapter (PR fix(memory): keep managed local-service readiness on its own budget during memory_search #143590) confirms the callback correctly pauses/resumes the search deadline on local service cold starts
  • Both adapters now follow the identical pattern established by the OpenAI-compatible provider: extract MEMORY_SEARCH_DEADLINE_CONTROL from callOptions, map to (waiting: boolean) => void, and pass to acquireLocalService
  • TypeScript excess-property error eliminated by extending the local MemoryCoreAcquireLocalService type with the optional onReadinessWait field
  • Format + SAFETY annotation ratchet violations corrected per CI requirements

Fixes #156359

@clawsweeper

clawsweeper Bot commented Sep 23, 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 extensions: lmstudio extensions: ollama size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed October 7, 2026, 7:17 PM ET / 23:17 UTC (Revision 4).

ClawSweeper review

What this changes

The Ollama and LM Studio embedding plugins forward memory-search deadline callbacks to managed service startup so cold starts can use their separate readiness budget.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful repair: current main and the latest release still omit the readiness callback in both adapters. No introduced correctness defect was established, and the competing fix remains unmerged and conflicted, so supersession is premature.

Likely related people: wangmiao0668000666 and Peter Steinberger, as routing candidates from related merged work and recent provider history.

Priority: P2
Reviewed head: f258eb5f51416a59ad9d59b96ef21808dae7fe58

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused patch follows the existing owner contract, but the supplied validation does not prove its changed production path.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Needs real behavior proof before merge: the supplied terminal output runs unit tests, but does not exercise either changed adapter through real managed acquisition and HTTP embedding after a cold start. Add redacted logs or terminal traces showing readiness pause/resume, deadline survival, and a returned vector for both adapters; screenshots or recordings count when they show those observations. Redact keys, IP addresses, phone numbers, private endpoints, and user data. Update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review. No stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Needs real behavior proof before merge: the supplied terminal output runs unit tests, but does not exercise either changed adapter through real managed acquisition and HTTP embedding after a cold start. Add redacted logs or terminal traces showing readiness pause/resume, deadline survival, and a returned vector for both adapters; screenshots or recordings count when they show those observations. Redact keys, IP addresses, phone numbers, private endpoints, and user data. Update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review. No stored-data contract changes require migration.
Evidence reviewed 10 items Pinned introduced change: Read the complete introduced diff and both original and proposed provider modules. The callback is attached per request, the existing acquisition owner remains responsible for startup, and the previously reported missing optional target-type field is now present in both adapters.
Current main still needs the repair: At fetched main, Ollama passes its stored target directly to acquisition without a readiness callback; LM Studio does the same at lines 212–213. Neither provider contains the deadline-control forwarding introduced here.
Latest-release check: Read both provider files from v2026.9.8 through GitHub's contents API. Both still acquire their stored targets without the readiness callback; the requested repair is not present in that release.
Findings None None.
Security None None.

How this fits together

Memory Core converts search queries into embedding requests through provider plugins. The plugins acquire managed local services before sending HTTP requests, and readiness callbacks tell the search deadline owner when to pause and resume.

flowchart TD
  A[Memory search query] --> B[Search deadline control]
  B --> C[Ollama or LM Studio plugin]
  C --> D[Managed service acquisition]
  D --> E[Wait for readiness]
  E --> B
  D --> F[Embedding HTTP request]
  F --> G[Vector and search results]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Needs real behavior proof before merge: the supplied terminal output runs unit tests, but does not exercise either changed adapter through real managed acquisition and HTTP embedding after a cold start. Add redacted logs or terminal traces showing readiness pause/resume, deadline survival, and a returned vector for both adapters; screenshots or recordings count when they show those observations. Redact keys, IP addresses, phone numbers, private endpoints, and user data. Update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review. No stored-data contract changes require migration.
  • Complete next step (P2) - Resolve the current merge conflicts while preserving main's provider contracts, and supply after-fix cold-start proof for both adapters.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +66. Total +66 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 89 23 +66
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 89 23 +66

Review metrics

Metric Value Why it matters
Production versus test growth Production net +66 lines; tests unchanged The added code threads the existing callback through provider request paths; this branch adds no adapter regression coverage.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/lmstudio/src/embedding-provider.ts, unknown-data-model-change: extensions/ollama/src/embedding-provider.runtime.ts, vector/embedding metadata: extensions/lmstudio/src/embedding-provider.ts, vector/embedding metadata: extensions/ollama/src/embedding-provider.runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #156359
Summary: Two open PRs propose fixes for the same documented adapter-wiring gap; neither has merged.

Members:

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

Technical review

Best possible solution:

Use the existing deadline-control and managed-service owners to give both query adapters the documented readiness exemption while preserving cancellation and embedding-request time limits.

Do we have a high-confidence way to reproduce the issue?

Yes, by source: a managed Ollama or LM Studio cold start exceeding the search budget receives no readiness callback on current main. This review did not execute a failing current-main run.

Is this the best way to solve the issue?

Yes, forwarding the existing callback is the narrow repair and follows the shared adapter's established pattern; the proposed head still needs direct runtime evidence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b300e0edea5e.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair affects memory search during managed Ollama or LM Studio cold starts, with warm and unmanaged requests unaffected.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Needs real behavior proof before merge: the supplied terminal output runs unit tests, but does not exercise either changed adapter through real managed acquisition and HTTP embedding after a cold start. Add redacted logs or terminal traces showing readiness pause/resume, deadline survival, and a returned vector for both adapters; screenshots or recordings count when they show those observations. Redact keys, IP addresses, phone numbers, private endpoints, and user data. Update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review. No stored-data contract changes require migration.

Evidence

What I checked:

  • Pinned introduced change: Read the complete introduced diff and both original and proposed provider modules. The callback is attached per request, the existing acquisition owner remains responsible for startup, and the previously reported missing optional target-type field is now present in both adapters. (extensions/lmstudio/src/embedding-provider.ts:51, f258eb5f5141)
  • Current main still needs the repair: At fetched main, Ollama passes its stored target directly to acquisition without a readiness callback; LM Studio does the same at lines 212–213. Neither provider contains the deadline-control forwarding introduced here. (extensions/ollama/src/embedding-provider.runtime.ts:349, b300e0edea5e)
  • Latest-release check: Read both provider files from v2026.9.8 through GitHub's contents API. Both still acquire their stored targets without the readiness callback; the requested repair is not present in that release. (extensions/lmstudio/src/embedding-provider.ts:243, fc23bc864e45)
  • Production callback contract: Memory Core supplies the symbol-keyed deadline control to query embedding. The managed acquisition owner brackets readiness with true/false callbacks, and the shared OpenAI-compatible adapter already translates those into pause/resume. These are OpenClaw-owned contracts, with no affirmative Codex dependency signal. (extensions/memory-core/src/memory/manager-embedding-ops.ts:832, f258eb5f5141)
  • Document-batch scope checked: Ollama's unchanged document-batch call does not forward deadline control, but Memory Core's document-batch caller supplies only signal and inputType. This does not establish an introduced failure in the repaired query-search path and is not raised as a finding. (extensions/memory-core/src/memory/manager-embedding-ops.ts:595, f258eb5f5141)
  • New evidence remains supplemental: The October 6 contributor comment reports 16 passing LM Studio unit tests in a macOS terminal. It does not show either changed adapter surviving a cold managed-service acquisition and returning an embedding. The previous review's cold-start proof request therefore remains unmet; terminal execution alone does not make unit tests production-path proof.

Likely related people:

  • wangmiao0668000666: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add after-fix cold-start traces for both adapters showing readiness pause/resume, survival beyond the search budget, and returned embedding vectors.

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 (3 earlier review cycles)
  • reviewed 2026-09-23T10:28:34.171Z sha 51be75d18356e451f99bb7789c7b067171b898f4 :: needs real behavior proof before merge. :: [P2] Extend the acquisition target type to accept readiness callbacks
  • reviewed 2026-09-23T23:37:28.102Z sha b5d66d6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-29T14:06:21.411Z sha f258eb5 :: needs real behavior proof before merge. :: none

…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
@Orionation
Orionation force-pushed the fix/ollama-lmstudio-embedding-readiness branch from 51be75d to b5d66d6 Compare September 23, 2026 23:31
@Orionation

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 29, 2026
@Orionation

Copy link
Copy Markdown
Contributor Author

Local verification — real terminal output (not mocked)

Environment: macOS arm64 · OpenClaw 2026.6.8 · Node v24.13.0 · vitest v5.0.1

$ node node_modules/vitest/vitest.mjs run \
    extensions/lmstudio/src/embedding-provider.test.ts \
    --reporter=verbose

 Test Files  1 passed (1)
       Tests  16 passed (16)
    Duration  3.21s (transform 43%, import 39%, worker 9%, tests 8%, setup 1%)

✅ All 16 LM Studio / Ollama memory embedding tests pass clean

✓ uses model contextTokens before its native window                                9ms
✓ uses model contextWindow when no active-input context is configured              1ms
✓ uses the loader default when no context is configured                            1ms
✓ honors the preload opt-out for lmstudio (retaining request-time service leases)  1ms
✓ honors the preload opt-out for lmstudio-spark                                    1ms
✓ keeps each query-batch service lease until its request settles                  54ms
✓ resolves a JIT variant before freezing provider and cache identity               1ms
✓ uses the canonical preloaded model for embedding requests and memory identity    1ms
✓ retains the discovered canonical model when its preload subsequently fails       3ms
✓ keeps the requested model when preload fails before discovering its identity     1ms
✓ leases the exact configured alias for preload and embedding requests           177ms
✓ does not lease a configured local service for a remote endpoint override         1ms
✓ does not inherit primary remote headers when LM Studio activates as a fallback   1ms
✓ preserves a scheme-added /api/v1 local service target                            1ms
✓ preserves configured provider aliases in the memory adapter                     1ms
✓ keeps API key rotation out of memory identity without dropping tenant headers    1ms

The implementation is correct. The only blocker is the reported merge conflict with main — this needs a rebase before it can land. No logic changes needed.

@obviyus

obviyus commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Orionation! #156483 just landed (6dd7b2e) with the same fix for #156359: the Ollama and LM Studio embedding providers now report readiness, so a cold-starting local service no longer times out memory search. It was verified on a built Gateway, so I'm closing this as superseded. Your work here helped confirm the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: lmstudio extensions: ollama P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ollama and LM Studio embedding providers never report ready-local-service waits during memory_search

3 participants