Skip to content

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

Closed

Description

@wangmiao0668000666

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

memory_search's readiness-budget fix added onReadinessWait to ProviderLocalServiceTarget, but only the OpenAI-compatible embedding provider sets it; the bundled Ollama and LM Studio embedding providers build their target without it, so a managed cold-start on those providers still consumes the whole search deadline.

Steps to reproduce

  1. Configure a managed local service for an Ollama or LM Studio embedding provider, e.g. models.providers.<id>.localService with a cold start near or exceeding the memory_search budget.
  2. Run memory_search.
  3. The service-acquisition wait is not paused, so the search deadline fires mid-startup and aborts the search.

By inspection this is the exact symptom #143590 set out to fix; the same configuration on an openai-completions provider survives because that provider does report the wait.

Expected behavior

docs/gateway/local-model-services.md states the behavior generically:

During memory_search, managed embedding startup uses readyTimeoutMs instead of the search and query-embedding timeouts. Those timers resume after the service is ready.

The same page names all three adapters when describing the feature (line 24: "Ollama, LM Studio, or OpenAI-compatible adapter"). llama-cpp is covered because it delegates to the OpenAI-compatible generic adapter.

Actual behavior

onReadinessWait is assigned in exactly one production file. git grep onReadinessWait over the tree yields the type (src/agents/provider-local-service-target.ts:13), the owner (src/agents/provider-local-service.ts:175,226), the one assignment (src/plugins/openai-compatible-embedding-provider.ts:352), and tests.

Neither bundled provider sets it:

  • Ollama — extensions/ollama/src/embedding-provider.runtime.ts:399-404 builds localServiceTarget as { providerId, baseUrl, headers } and calls client.acquireLocalService(client.localServiceTarget, signal) at line 415 with no onReadinessWait key.
  • LM Studio — extensions/lmstudio/src/embedding-provider.ts:242-248 builds localServiceTarget as { providerId, baseUrl, headers } and calls acquireLocalService(localServiceTarget, signal) at line 257, likewise without the key.

The owner brackets the entire cold-start wait with the hook (src/agents/provider-local-service.ts:175 / 226):

target.onReadinessWait?.(true);
try {
  ...
  healthy ? await probeHealth(...) : false;
  ...
  managed.starting = startAndWaitForLocalService({...});
  await waitForAbort(managed.starting, signal);
  ...
} finally {
  target.onReadinessWait?.(false);
}

The property is optional on the target type (provider-local-service-target.ts:13, documented as "Reports readiness waits only; reconciliation and request work stay outside"), so omitting it is type-valid and the ?. call degrades to a silent no-op. Construction of the target literals in both providers is not type-checked against the full key set.

Logs

NOT_ENOUGH_INFO — I verified this by source inspection and did not run a live cold-start Ollama or LM Studio managed service.

Screenshots, recordings, and evidence

Not applicable to the wiring gap itself. The relevant test coverage does not reach it:

  • src/plugins/openai-compatible-embedding-provider.test.ts asserts the provider forwards the callback, using a mock acquirer hard-coded to invoke target.onReadinessWait?.(true/false).
  • src/agents/provider-local-service.readiness.test.ts constructs a target with the callback already attached — it verifies the acquire side, not that each provider wires it.

No test in extensions/ollama or extensions/lmstudio references onReadinessWait, and #143590 touched no file in either extension.

Impact and severity

Affected: deployments using a managed local service with the Ollama or LM Studio embedding provider and running memory_search across a cold start.
Severity: Moderate — memory_search fails where the documented readiness budget should have covered it.
Frequency: Intermittent; only when service startup approaches or exceeds the search budget. A warm service is unaffected.
Consequence: memory search aborts during cold start instead of waiting out readyTimeoutMs.

Additional information

Not a regression from #143590 — before it, no provider paused at all. This is an incompleteness in that change: the fix landed on the one adapter that happens to be shared by llama-cpp, leaving the two dedicated provider extensions on the old behavior while the docs describe the new one generically.

The repair mirrors the existing assignment: set onReadinessWait when building localServiceTarget in both providers, forwarding to the same deadline control the OpenAI-compatible adapter uses. Coverage should assert the wiring per provider rather than only that the acquire owner invokes a pre-attached callback.

Disclosure: I authored #143590. I filed this as an issue rather than a PR because proving it end-to-end needs a live cold-start Ollama or LM Studio managed service, which I have not run, and I would rather not put a patch behind an unproven reachability claim.

Activity

  1. added
    P2
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    clawsweeper:source-repro
    impact:session-state
    issue-rating: 🦞 diamond lobster
    no-stale
    on Sep 23, 2026
  2. clawsweeper commented on Sep 23, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work. Reviewed September 28, 2026, 9:26 AM ET / 13:26 UTC.

    Summary
    Current main still has the reported readiness-wait gap. The reporter’s follow-up provides a controlled failure and comparison, and two open PRs propose fixes; neither has merged.

    Reproducibility: yes. by source inspection: both provider entry paths omit a callback that the deadline owner invokes only when present. The reporter also supplied a controlled failure and comparison; this review did not run a current-main cold start.

    Root-cause cluster
    Relationship: canonical
    Canonical: #156359
    Summary: This issue identifies the remaining provider-wiring gap; two open PRs propose fixes, while the earlier merged change established the shared readiness mechanism.

    Members:

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

    Next step
    Two open PRs already claim this fix; review and reconcile those candidates rather than dispatching a third implementation.

    Review details

    Best possible solution:

    Land one focused provider-wiring fix with coverage for both adapters and their unchanged non-managed paths, preserving the reported cold-start proof.

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

    Yes, by source inspection: both provider entry paths omit a callback that the deadline owner invokes only when present. The reporter also supplied a controlled failure and comparison; this review did not run a current-main cold start.

    Is this the best way to solve the issue?

    Yes. Forwarding the existing per-call deadline control through each provider’s service-acquisition target is narrower than adding another timer or policy owner.

    AGENTS.md: found and applied where relevant.

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

    Label changes

    Label changes:

    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • remove clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label.
    • remove clawsweeper:queueable-fix: Current issue advisory state no longer selects this label.

    Label justifications:

    • P2: A managed local embedding cold start can abort memory search, but warm services and other provider paths are unaffected.
    • impact:session-state: The failure suppresses semantic memory retrieval during affected searches.
    Evidence reviewed

    What I checked:

    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)
    How this review workflow works
    • 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.
  3. clawsweeper commented on Sep 23, 2026

    @clawsweeper
    Contributor

    🦞⚠️
    Automatic implementation stopped before completion.
    Reason: The automatic implementation worker stopped before all deterministic gates completed. Open the workflow run for the exact blocker.
    Worker: https://github.com/openclaw/clawsweeper/actions/runs/35846347914

    Automatic implementation progress:

  4. wangmiao0668000666 commented on Sep 23, 2026

    @wangmiao0668000666
    ContributorAuthor

    Adding real behavior proof, which the initial report lacked.

    What was proven

    Both bundled providers were driven through the real deadline-control mechanism (createMemorySearchDeadlineControl) with a real slow managed-service acquire (300 ms) against a 150 ms search budget, using the providers' own real embed() entry points. Same harness, same timings; only the provider differs.

    Ollama (extensions/ollama/src/embedding-provider.runtime.ts):

    PROOF acquire calls: 1
    PROOF target keys: ["baseUrl","headers","providerId"]
    PROOF target has onReadinessWait: false
    PROOF budget expired during acquire: true
    

    No pause was reported at all — the budget ran its full 150 ms and expired while the provider was still waiting for readiness.

    Control — shared OpenAI-compatible provider (src/plugins/openai-compatible-embedding-provider.ts), which does wire the callback:

    CONTROL budget saw: pause at 0 ms
    CONTROL budget saw: resume at 303 ms
    CONTROL target keys: ["baseUrl","headers","onReadinessWait","providerId"]
    CONTROL target has onReadinessWait: true
    CONTROL budget expired during acquire: false
    

    The pause at 0 ms and resume at 303 ms bracket the acquire exactly, and the budget survived the 300 ms wait despite being only 150 ms.

    Ollama Shared provider
    target keys baseUrl, headers, providerId baseUrl, headers, **onReadinessWait**, providerId
    pause / resume never 0 ms / 303 ms
    150 ms budget vs 300 ms acquire expired survived

    The only difference between the two runs is the provider, so the outcome is attributable to the missing callback rather than to the measurement harness.

    Harness note

    The budget replica mirrors the owner's watchdog in extensions/memory-core/src/memory/manager-embedding-ops.ts:218-236, including its documented rule that a phase starting after the budget is already consumed gets no exemption. An earlier version of this harness armed the budget at construction time, which measured module-load latency instead of the operation and produced a false negative for both providers; arming immediately before embed() is what makes the control pass and the contrast meaningful.

    Still not proven

    No live cold-start Ollama or LM Studio managed service was run; the acquire hook is a real-shaped stub rather than a real child process. The claim being proven is narrower and exact: the Ollama and LM Studio providers never set onReadinessWait, so the owner's target.onReadinessWait?.(...) is a no-op for them, while it fires for the shared provider. extensions/lmstudio/src/embedding-provider.ts:257-258 builds and passes its target identically to Ollama's, so the same result applies there without a separate run.

  5. added a commit that references this issue on Sep 23, 2026
    b5d66d6
  6. added
    clawsweeper:linked-pr-open
    clawsweeper:no-new-fix-pr
    and removed
    no-stale
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    on Sep 26, 2026
  7. added a commit that references this issue on Oct 8, 2026
    6dd7b2e
  8. added a commit that references this issue on Oct 9, 2026
    cac6427
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:linked-pr-openclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:session-stateissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions