Skip to content

Point unsloth start openclaw memory search at the Unsloth embeddings API - #10320

Merged
danielhanchen merged 7 commits into
unslothai:mainfrom
NilayYadav:fix-start-openclaw-memory-search
Sep 6, 2026
Merged

danielhanchen merged 7 commits into
unslothai:mainfrom
NilayYadav:fix-start-openclaw-memory-search

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

The config that unsloth start openclaw generates never set memory.search, so OpenClaw fell back to its own default embedding provider, openai. Memory search is on by default, so a session that is meant to run entirely on a local model was reaching for OpenAI embeddings.

This points memory search at Studio instead: provider openai-compatible, the same base URL and session key already written for the chat provider, and Studio's own embedding model name as the model, read from Studio at connect time so the string changes when the Settings model changes. It falls back to default on a server without that route.

Memory embeddings then run on the local embedding model through Studio's /v1/embeddings.

Depends on #10315 and must merge after it. That PR makes /v1/embeddings serve from the configured embedding model when the loaded GGUF cannot, and accepts that model's own name in the request. Against main today the route still answers 501, so this stays a draft until #10315 lands.

Related: #10316 stops the openclaw session from inheriting OPENAI_API_KEY.

@NilayYadav NilayYadav changed the title Point unsloth start openclaw memory search at the Unsloth embeddings API Stop unsloth start openclaw sending memory embeddings to OpenAI Sep 4, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-06T12:06:43.614454Z 58c52a6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dd270aeb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8dd270aeb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@NilayYadav NilayYadav changed the title Stop unsloth start openclaw sending memory embeddings to OpenAI Point unsloth start openclaw memory search at the Unsloth embeddings API Sep 4, 2026
@NilayYadav
NilayYadav marked this pull request as draft September 4, 2026 21:48
@NilayYadav
NilayYadav force-pushed the fix-start-openclaw-memory-search branch from 3b3432d to 902b7bb Compare September 4, 2026 21:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 902b7bbcea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01cfd8932f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread unsloth_cli/commands/start.py Resolved
@NilayYadav
NilayYadav marked this pull request as ready for review September 4, 2026 22:53
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 0ec418f0ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@NilayYadav

NilayYadav commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

GitHub Actions reproduction

Pinned head: 0ec418f0f. This PR depends on #10315, so the positive branch stacks fresh upstream main (971eb36f4) + #10315 (6ed62117e) + this PR. The negative branch is the same main + this PR only, with the same workflow, probe and dependencies. Both boot the real Unsloth server (serve-unsloth-run.sh, unsloth/gemma-3-270m-it-GGUF Q8_0, --disable-tools, model auto-switch at its default of off), run unsloth start openclaw --no-launch, read the generated openclaw.json, and then call the embeddings endpoint with exactly the model and key from that config while the chat GGUF is still loaded.

Generated memory.search block, identical on both branches (key redacted):

{"provider": "openai-compatible", "model": "unsloth/bge-small-en-v1.5", "fallback": "none",
 "remote": {"baseUrl": "http://127.0.0.1:18901/v1", "apiKey": "sk-unsloth-..."}}
Probe without #10315 with #10315
POST /v1/embeddings, model and key from the config, chat GGUF loaded 404 "not downloaded on this server" 200, 384-dim, model llama-server:unsloth/bge-small-en-v1.5:unsloth/bge-small-en-v1.5-GGUF
same, model unsloth/bge-small-en-v1.5-GGUF 404 200
700-word input 501 400 "'input' exceeds the 510-token limit"
510-word input 501 200
511-word input 501 400 "510-token limit"
POST /v1/chat/completions (control) 200 200
chat GGUF still loaded afterwards yes yes

The "without #10315" column is the expected state of main today, not a defect in this PR: the endpoint the config names cannot serve embeddings behind a chat model until #10315 lands. The recipe does not print unset OPENAI_API_KEY on either branch because #10316 is not in this stack.

Harness: workflow and probe.

Re-run on the converged heads (main 55418be + #10315 8cac7d484 + this PR 810d818b8): run 33934255306, same probe, every assertion passes.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed main never writes memory.search in unsloth_cli/commands/start.py, so an openclaw session that is meant to stay local reaches OpenAI for embeddings, and this points it at Studio instead. Since Studio's /v1/embeddings cannot serve it until #10315 lands, could you confirm the merge order so memory search does not start failing for people it works for today?

…ts embedder

The probe returned the string "default" when the settings route did not answer, and
that went into the config as memory.search.model next to fallback: "none". That names a
model Studio will not serve, with no fallback left, which is the one shape OpenClaw
cannot degrade out of: every memory request fails against Studio and the search returns
nothing. Verified against openclaw 2026.9.2 driven by the config this writes.

Write provider: "none" instead, which is OpenClaw's own value for keyword-only memory
search. It makes no network call, never reaches OpenAI, and openclaw memory search still
returns ranked hits (checked live: score 0.647 on the same corpus that scores 0.598 with
embeddings). The stale remote is dropped so a reused --persist config stops carrying an
endpoint and key for a provider that is no longer pointed at it.

Two smaller things on the same probe: strip the name, since OpenClaw sends it to
/v1/embeddings verbatim and Settings stores what was typed; and let a typer.Exit through,
since it is a RuntimeError subclass and the broad catch turned a deliberate CLI abort
into a silently degraded config.
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 6, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Went through this one properly: simulated it, ran it against a real Studio with the real OpenClaw client, and pushed three fixes to the branch (17ba1748d). Merge order confirmed below, with the evidence you asked for.

Before and after, measured rather than assumed

Booted a real Studio on 127.0.0.1:18901 twice from the same machine, once from main + this PR and once from main + #10315 + this PR, and posted to /v1/embeddings with exactly the model string the generated openclaw.json names, with unsloth/gemma-3-270m-it resident as the chat model:

main + #10320 main + #10315 + #10320
nothing loaded 503 "No GGUF model loaded" 200, 384-dim, sentence-transformers:unsloth/bge-small-en-v1.5
chat model resident 404 "The model 'unsloth/bge-small-en-v1.5' is not downloaded on this server" 200, 384-dim
chat model after the attempt still resident still resident

So the ordering is real, and the failure without #10315 is a 404 rather than the 501 the description predicts, because the request reaches _auto_switch_from_request_body and is treated as a model to load. Worth noting the eviction I was worried about did not happen: with auto-switch at its default of off the chat model survives. It stays a live hazard only where auto-switch is on and the Settings embedding model names a downloaded GGUF, which #10315 closes by matching _names_studio_embedder before the switch.

Full path end to end, with the real client (openclaw 2026.9.2, Node 22.23.2), no mocks:

$ openclaw memory status --deep
Provider: openai-compatible (requested: openai-compatible)
Model: unsloth/bge-small-en-v1.5
Embeddings: ready

$ openclaw memory search "what does the sloth drink"
0.598 memory/notes.md:1-6

and Studio's own log shows the POST /v1/embeddings 200s that produced that score. Memory embeddings really do run on the local model now. Chat kept working throughout: 8 concurrent embedding requests (twice the admission cap) plus a chat completion all returned 200, and the chat model was never unloaded.

What I changed on the branch

1. "default" was a config OpenClaw cannot degrade out of. When the settings route did not answer, the probe wrote model: "default" next to fallback: "none". That names a model Studio will not serve with no fallback left, so every memory request fails and search returns nothing. I hit this for real by a different route: switching the Settings embedding model marks the new model download-pending, and until that finishes /v1/embeddings fails, at which point memory status reports Embeddings: unavailable and search returns "No matches".

The branch now writes provider: "none", OpenClaw's own value for keyword-only memory search. It makes no network call, never reaches OpenAI, and search still returns ranked hits: the same corpus that scores 0.598 with embeddings scores 0.647 under keyword-only. Verified against the shipped package, not inferred. The stale remote is dropped too, so a reused --persist config stops carrying an endpoint and key for a provider no longer aimed at it.

2. The model name is now stripped. OpenClaw sends memory.search.model to /v1/embeddings verbatim (normalizeModel only strips an openai-compatible/ prefix), and Settings stores what was typed, so " unsloth/bge-small-en-v1.5 " travelled all the way into the request.

3. A typer.Exit is no longer swallowed. It is a RuntimeError subclass, so the bare except Exception would turn a deliberate CLI abort into a silently degraded config. Not reachable today with error = None, but one added error = argument away.

Things you should know about, that I did not change

Existing memory indexes go stale on the first run after this lands. OpenClaw fingerprints its index on provider and model, and this PR changes both. Live:

Index identity: index was built for model unsloth/bge-small-en-v1.5,
                expected sentence-transformers/all-MiniLM-L6-v2 (owner: configuration, code: model)
Vector search: paused until memory is rebuilt
Fix: Run: openclaw memory status --index --agent main

Nothing is corrupted and OpenClaw reports it clearly with the fix, but the same thing happens every time someone changes the Settings embedding model between --persist runs, and the CLI says nothing about it. Worth a line in the PR body at least; a one-line notice from unsloth start openclaw would be better, and I left that to you since it is your call how chatty that output should be.

OpenClaw's own gateway /v1/embeddings rejects this model string. resolveEmbeddingsTarget in the shipped bundle splits the configured model on the first slash and reads the prefix as a provider, so unsloth/bge-small-en-v1.5 yields provider unsloth, which is not openai-compatible, and that route answers 400. Memory search itself is unaffected, since it uses the model verbatim. No slash-free string can name a Hub repo, so there is nothing to fix here; it is a limitation to know about. Source-level finding, not exercised live.

One wasted GET. The probe is evaluated as an argument to write_openclaw_config, so it runs even when the config turns out to be unparseable and nothing is written. Not worth restructuring the call site for; pinned by a test on my side so the cost is a known one.

Simulations

All in an isolated uv venv on Python 3.12, matching the Repo tests (CPU) job.

  • CLI matrix, 70 cases. Probe failure modes (401/403/404/500/502, a refused redirect, URLError(ConnectionRefusedError), DNS, TimeoutError, non-JSON body, non-UTF-8 body, OSError), odd payload shapes (empty, null, list, string, int bodies; missing, empty, blank, non-string names), a 5 MB body, 15 odd model names (CJK, emoji, RTL, quotes, $, backticks, spaces, backslashes, 512 chars, :QUANT), config merge semantics (missing, corrupt, null top level, non-dict memory, non-dict memory.search, sibling keys, byte-for-byte idempotency, 0600 with the second key copy), and the Windows/WSL/POSIX recipe branches under a simulated os.name. 70/70 on the fixed head; 3 of them fail on the head before it, which is how I found items 1 to 3.
  • Studio suites on the merged stack. test_openai_embeddings_studio_fallback.py, test_rag_embeddings.py, test_rag_embed_llama_server.py, test_openai_auto_switch.py, test_middleware.py, test_preview_routes.py, test_active_generations.py: 973 passed, 1 skipped. Same suites without Studio: serve /v1/embeddings from the configured embedding model when the loaded GGUF cannot #10315: 909 passed, 1 skipped, no regression either way.
  • Full unsloth_cli/tests on the fixed head: 1189 passed, 6 skipped.
  • Hardware matrix, 63 cases over [Windows, Linux, WSL, macOS] x [NVIDIA, AMD, CPU-only], driving the real _resolve_auto with the probes it actually calls stubbed per platform. Every cell resolves to a placeable backend, including with no llama-server binary present.
  • Version skew, live. An unsloth CLI from upstream main against a Studio with the full stack writes no memory.search at all, so old installs are untouched. Upgrade writes it. Downgrading the CLI afterwards leaves the block in place, which is fine while Studio still serves it and is another reason the ordering matters.
  • Windows and macOS. Simulating os.name in-process is not the same as running there, so the suite plus a repo-native copy of the matrix is running on real windows-latest and macos-15 runners on a staging replica rather than in this queue.

What this host cannot answer: real AMD/ROCm and real Apple silicon. Those cells are simulated at the decision function only, so backend selection is covered and numerical behaviour on that hardware is not. No browser surface is involved: this PR touches two Python files and #10315 touches no frontend file.

Ready from my side once #10315 lands. I pushed one fix there too, for the case above where an actionable "model is not downloaded yet" became a 502 "An internal error occurred" by the time it reached memory search.

@danielhanchen

Copy link
Copy Markdown
Member

Cross-platform results, since simulating os.name in-process is not the same as running there.

Ran this branch plus a repo-native copy of the 70-case matrix on real runners in a staging replica, and ran upstream main alone through the identical Windows lane as a control.

lane result
macos-15 pass
windows-latest, this branch + matrix 9 failed, 651 passed, 20 skipped
windows-latest, upstream main alone (control) 9 failed, 578 passed, 18 skipped

The same nine, byte for byte:

test_write_codex_subagent_bridge_keeps_parent_credentials_out   assert (33206 & 63) == 0
test_write_codex_parent_overlay_preserves_user_state_and_instructions
test_no_launch_last_line_is_self_contained                      KeyError: 'CODEX_HOME'
test_no_launch_claude_last_line_blanks_conflicting_auth
test_start_studio_server_builds_command_and_waits               assert '-X' == 'run'
test_connect_pi_as_subagent_preserves_cloud_parent[False]
test_connect_pi_as_subagent_preserves_cloud_parent[True]
test_session_config_falls_back_when_existing_temp_root_is_unwritable
test_session_config_falls_back_when_studio_auth_root_is_unwritable

So this PR introduces no Windows regression: those nine fail on main without it. They are the usual Windows gaps in this suite (POSIX mode bits asserted on a filesystem that has none, CODEX_HOME, the pi subagent, the studio server argv), which is presumably why Repo tests (CPU) has no Windows leg. Not this PR's problem, but worth knowing they are there.

Every openclaw test passed on Windows and macOS, including the new ones, and all 70 matrix cases passed on Windows (two skip there by design: the POSIX one-liner and the WSL bridge). That covers the branches Linux never reaches, in particular _print_env's PowerShell form and _powershell_quote, which have no coverage in the repo today because the recipe assertions branch on the host's real os.name.

The ubuntu-latest lane is still queued behind the org's runners; this repo's own Linux CI is already green on the PR head and I ran the full unsloth_cli suite locally on Linux (1189 passed, 6 skipped). I will note the result here if it comes back anything other than green.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 6, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 6, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 6, 2026
@unslothai unslothai deleted a comment from NilayYadav Sep 6, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: c9031aa33c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

21 added comment lines to 11. Every surviving line still names a mistake the next reader
would otherwise make: why None is not a model name, why typer.Exit is caught separately,
why the model is stripped, and why the remote is cleared.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 6, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58c52a6afb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

combination OpenClaw cannot degrade out of. The caller writes provider "none" instead.
"""
try:
info = _http_json("GET", f"{base}/api/settings/embedding-model", key, timeout = 10)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify that Studio can serve the reported embedder

When this CLI connects to an already-running or remote Studio version from before the dependent embeddings change, this GET can still succeed because studio/backend/routes/settings.py::get_embedding_model already existed, while that version's openai_embeddings only proxies to the loaded GGUF and cannot serve the configured sentence-transformers model. The successful response therefore selects openai-compatible instead of keyword-only mode, causing OpenClaw memory requests to fail against the usual non-embedding chat model (or trigger an unwanted model switch when auto-switching is enabled). Use an explicit server capability/version signal rather than treating the settings route's existence as proof that /v1/embeddings supports this model.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this, though the facts are right and I measured them rather than reasoning about them.

I booted a real Studio twice on the same machine, once from main + this PR and once from main + #10315 + this PR, and posted to /v1/embeddings with exactly the model string this config writes, with a chat model resident:

So yes, the settings route existing (since #6800, 2026-07-02) does not imply /v1/embeddings can serve that model. The chat model was not evicted in that run: auto-switch is off by default, so eviction needs auto-switch on AND the Settings embedding model to name a downloaded GGUF.

Where I disagree is the remedy. There is no capability signal to read: /version (llama_compat.py:183) returns a bare version string and there is no capability endpoint, so gating on it would mean hardcoding the release #10315 lands in, which does not exist while this PR is open and is wrong for dev builds and forks. Probing /v1/embeddings for real is the only honest capability test, and it loads the embedding model, so unsloth start openclaw would stall on a cold Studio and could trigger a download.

The case it guards is also narrow by construction: the CLI and the backend ship in one wheel (pyproject includes unsloth_cli*, studio and studio.backend* in a single distribution), so a co-installed pair always matches. The skew needs UNSLOTH_STUDIO_URL aimed at a remote or stale Studio, and this PR already declares that it merges after #10315. Nothing else in start.py version-gates either; the file's stated design is to try the call and handle the failure.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 6, 2026
@danielhanchen
danielhanchen merged commit 083113b into unslothai:main Sep 6, 2026
45 checks passed
danielhanchen added a commit that referenced this pull request Sep 6, 2026
… the loaded GGUF cannot (#10315)

* Studio: serve /v1/embeddings from the configured embedding model when the loaded GGUF cannot

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Untrack the studio embeddings fallback from the llama keep-warm slot

* Hold the embeddings admission permit until the worker thread exits

* Pin the embeddings helpers to one model, report its real identity, free the preview guard

* Close the embeddings monitor row when the request is cancelled

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make the admitted-tally assertion relative to the suite's shared counter

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Serve the configured embedding model by name and enforce its token limit on the GGUF embedder

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Validate embeddings input before any switch, cap the limit at the running context and default prompt, hide local model paths

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Keep the proxy for a resident embedding GGUF that answers the requested name and hide Windows-shaped model paths

* Accept flat token arrays before switching, drop queued embeddings on disconnect, match aliases without probing and keep redacted local names unique

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Reject falsey encoding formats and apply the studio batch cap only on the fallback

* Studio: refuse a decisively named model with nothing loaded, and keep local identities unique

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Accept the advertised local identity as an alias, drop disconnected requests after admission and pin the matched model

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: size the embed server's batch to its context, and never advertise past it

* Release the embeddings permit when a cancellation lands in the final disconnect probe

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: trust a cold index less, keep the embed batch as shipped, and reject boolean token ids

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Match tagged identities in full, skip the chat-slot restore for default embedding requests, cache the limit only with both bounds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Keep the embedder's own message when the model just needs downloading

Picking a model in Settings and querying before its download finishes raises
EmbeddingModelDownloadRequiredError, whose message says exactly that and exactly what to
do. The catch-all mapped it through _friendly_error, which is written for llama-server
transport faults, so the caller got 502 "Embedding model failed: An internal error
occurred".

Reproduced live on a real Studio: with #10320 on top, the generated openclaw.json points
memory search at this route, so that string was the whole diagnosis the user saw --
openclaw memory status reported "Embeddings: unavailable, an internal error occurred"
for a condition the user could have fixed in one click. Switching the Settings model and
switching back is enough to reach it, since the new model is marked download-pending.

Return 409 with the model's own words for that error and for UnsafeEmbeddingModelError:
the request is fine, the server is not ready to serve it yet. Everything else keeps the
502.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Redact the model path from embedder errors, and fix two invalidation gaps

Three review items, each reproduced at head before it was touched.

Path leak in the 409 I added: _get resolves a cached model to its absolute snapshot
directory and hands that to _guard_model_security, which interpolates it into the error,
so returning str(exc) verbatim published the server's Hugging Face cache layout through
/v1/embeddings. The scan still runs on the snapshot; the message now names the configured
model, and the route puts a local model through the same hashed label the identity and
limit errors already use.

Identity redaction replaced substrings, not segments. A local model can be a bare relative
directory named transformers, which is_local_path accepts when it exists, and
sentence-transformers:transformers then became sentence-transformers-<hash>:transformers-<hash>.
Reproduced: embedding_identity_model returns None on that, so the identity the response
advertises is one _names_studio_embedder cannot match on the next request. Parse off the
backend tag and rewrite only the model and repo segments.

The token limit outlived the server it was measured on. Changing the custom llama.cpp path
makes _current stale and respawns, but _resolve_model_path fast-paths on the unchanged repo
and never reaches _adopt_model_path, so the cached value survived onto the new binary. It
clamps the GGUF context by the server's n_ctx and n_ubatch, whose defaults differ between
builds (llama.cpp server: -b 2048, -ub 512, --ctx-size 0 = from model, and n_ctx in /props
is per slot with an automatic slot count), so it is cleared next to the binary it came from.

The one existing test touched is a stub signature, not an assertion.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Type the GGUF backend's pending-download refusal like the sentence-transformers one

_resolve_model_path raises for exactly the condition EmbeddingModelDownloadRequiredError
names, with the same wording, but as a bare RuntimeError. So on the llama-server backend
the 409 added for this landed only on the sentence-transformers path, and the GGUF one
still returned 502 An internal error occurred: the same user-fixable state, answered two
different ways depending on which embedder the hardware picked.

Raised typed now. The route's redaction covers it: the message interpolates the configured
model, which is what the label substitution replaces, so a local model path does not travel
out with it.

Regression test fails on the untyped raise and passes here.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten the comments this PR added

127 added comment lines to 79. Cut the restatements and collapsed the rationale blocks to
the fact each one exists to carry: why the route untracks before encoding, why the permit
follows the worker thread rather than the awaiting task, why no -b/-ub is passed, why the
limit is not frozen while /props is silent, and #7454's rule about answering a decisive
reference from another embedding space.

* Guard a non-string model selector and redact a local GGUF repo under a hub model

* Let the security-gate stubs take the display argument

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refuse a stale embedding identity and bound the advert by the batch we launch with

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Take the physical batch from n_ubatch only

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <[email protected]>
Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants