Skip to content

fix(gateway): allow slash model ids in embeddings overrides - #161170

Merged
steipete merged 3 commits into
openclaw:mainfrom
xialonglee:fix/gap-embeddings-slash-model
Oct 10, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
xialonglee:fix/gap-embeddings-slash-model

Conversation

@xialonglee

@xialonglee xialonglee commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes HTTP 400 responses from /v1/embeddings when an explicitly configured model or x-openclaw-model override contains a slash, such as Ollama's library/bge-m3 or hf:org/model.

User Impact

Clients can use the complete embedding model ID with the agent's configured provider. A recognized prefix selecting a different provider still returns HTTP 400. The OpenAI model field remains an OpenClaw agent target.

Why This Change Was Made

The Gateway previously interpreted every slash as a provider separator. It now asks the existing embedding provider resolver whether the prefix names a provider; otherwise it forwards the full model ID. Redundant auto handling is removed from this consumer because memory configuration already owns that normalization.

Merged current main into the contributor branch and simplified the regressions into the existing HTTP fixture. Thanks @xialonglee for the original fix and regression; all contributor commits are preserved.

Compatibility: this changes request-time routing only. It does not write memory indexes or alter stored vectors, embedding metadata, schemas, migrations, configuration formats, or authentication. The after-proof reuses the isolated state/config created by main.

Evidence

Baseline: main ea6022cae60c509d8c0e8029ad8030557a917617. Candidate: 80c9550d4ec6ca86db2283d8521fcde245d5974b.

  • Fail-on-main proof: both added HTTP cases fail with expected 200 / received 400; the ordinary model case passes. Wall time 267.83 s.
  • Fixed full endpoint suite: 31/31 pass, wall time 252.05 s. The new cases take 28 ms and 29 ms using the existing suite-level Gateway. Whole-file wall time includes worker compilation, Gateway startup, and existing auth/lifecycle scenarios; no new Gateway boots or timers were added.
  • Scoped oxlint, core and Gateway-root test typechecks pass. Required ratchets and plugin inventory pass. Codex autoreview: scoped-clean through P2.
  • Full pnpm build passes (20m 44.4s on the shared host). The matching ollama/bge-m3 override also returns 200 with 1024 dimensions.
  • Exact-head CI run 38000747791 and openclaw/ci-gate passed. The checks-node-changed job took 254 s (whole-job duration, not isolated test-file timing); baseline ratchets took 94 s.
  • Production LOC +9/-9; tests +39/-23; docs +2/-0. No changelog changes.

Live proof uses the real built Gateway on port 19232 and real local Ollama and LM Studio models, with input ["alpha","beta"]:

Route/model Main Candidate
Native Ollama library/bge-m3 400 200, 1024 dimensions
Native Ollama library/nomic-embed-text 400 200, 768 dimensions
Ollama /v1, library/bge-m3 400 200, 1024 dimensions
Ollama /v1, library/nomic-embed-text 400 200, 768 dimensions
LM Studio text-embedding-nomic-embed-text-v1.5 200, 768 dimensions 200, 768 dimensions
Native Ollama agent, different openai provider override 400 400

The native/compatible agents use memory.search.provider values ollama and openai-compatible, with remote URLs http://127.0.0.1:11434 and http://127.0.0.1:11434/v1; LM Studio uses port 1234. Representative request:

curl -sS http://127.0.0.1:19232/v1/embeddings \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -H 'x-openclaw-model: library/bge-m3' \
  -d '{"model":"openclaw/native","input":["alpha","beta"]}'

The Gateway was started through pnpm openclaw --profile gateway-embeddings gateway run --port 19232 --bind loopback, with isolated OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH. Provider token usage is a separate PR; this routing change retains the existing usage response.

@clawsweeper

clawsweeper Bot commented Sep 29, 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 gateway Gateway runtime size: S labels Sep 29, 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 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The Gateway embeddings endpoint, which converts text into numeric vectors, accepts slash-containing model IDs without treating unknown prefixes as providers.

Example: A client requests embeddings with x-openclaw-model: library/bge-m3.

  • Before: The Gateway returns HTTP 400 because it interprets library as a different provider.
  • After: The configured Ollama provider receives library/bge-m3 and returns HTTP 200 with 1024-dimensional embeddings.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-level repair with real Gateway before/after proof, meaningful regressions, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The pinned candidate’s built Gateway was exercised through /v1/embeddings against real local Ollama and LM Studio models: slash IDs produce successful vectors, ordinary models remain successful, and a different recognized provider remains rejected. Source inspection confirms no stored-data contract changes, and the candidate reuses baseline config and state.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Embedding clients receive HTTP 400 for valid model names such as library/bge-m3.
Reason: This restores valid model requests within the established agent-scoped provider contract with a small, bounded repair.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still has the defect, the repair preserves the existing provider boundary, and no actionable patch findings remain.

Priority: P2
Reviewed head: 80c9550d4ec6ca86db2283d8521fcde245d5974b

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway exposes an authenticated OpenAI-compatible embeddings endpoint. It selects an agent’s configured embedding provider, forwards input text and the selected model, and returns vectors.

flowchart TD
 A[Client text and model override] --> B[Gateway authentication and agent selection]
 B --> C[Configured embedding provider]
 C --> D{Recognized provider prefix?}
 D -->|Unknown prefix| E[Preserve complete model ID]
 D -->|Matching provider| F[Use model after prefix]
 D -->|Different provider| G[HTTP 400]
 E --> H[Configured provider returns vectors]
 F --> H
Loading

Technical review

Best possible solution:

Keep model parsing in the Gateway handler and reuse the existing provider resolver while preserving configured-provider selection.

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

Yes. Current-main source deterministically rejects library/bge-m3 for a configured Ollama provider, and the supplied baseline live run observes HTTP 400; this read-only review did not execute target code.

Is this the best way to solve the issue?

Yes. Consulting the existing provider resolver repairs the parsing error at its owner without adding another routing path or changing provider selection.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still rejects opaque slash model IDs: The fetched main resolver splits every slash-containing value and rejects prefixes unequal to the configured provider; library/bge-m3 therefore still reaches HTTP 400. (src/gateway/embeddings-http.ts:150, a3cb823779cb)
  • Narrow routing repair: The introduced delta uses the existing config-aware provider resolver to distinguish provider references from opaque model IDs; all successful paths retain configuredProvider. (src/gateway/embeddings-http.ts:145, 80c9550d4ec6)
  • After-fix real Gateway proof: The complete PR body pins baseline ea6022c and candidate 80c9550. Its real built Gateway results show native and OpenAI-compatible Ollama library/bge-m3 requests changing from 400 to 200 with 1024 dimensions, library/nomic-embed-text changing to 200 with 768 dimensions, LM Studio remaining successful, and a different recognized provider remaining rejected. (80c9550d4ec6)
  • Regression coverage and earlier concern: The existing HTTP fixture separately exercises a configured library/bge-m3 model and an hf:org/model header override and checks the model received upstream. The body reports both cases failing on baseline and the complete endpoint suite passing on candidate, addressing the earlier regression-input concern. (src/gateway/embeddings-http.test.ts:414, 80c9550d4ec6)
  • No migration or changed default: The handler only resolves a provider, embeds request text, and returns vectors. It writes no index or embedding metadata; memory configuration already normalizes auto to openai, so removing the consumer normalization preserves that default. The live candidate reuses baseline state and config. (src/agents/memory-search.ts:150, 80c9550d4ec6)
  • Original endpoint intent: The feature-history search leads to feat(gateway): add missing OpenAI-compatible endpoints (models and embeddings) #53992, whose stated purpose is authenticated OpenAI compatibility and embedding-driven integrations; the original handler constrains provider selection. (src/gateway/embeddings-http.ts:157, eaad4ad1be38)

Likely related people:

  • Vincent Koc: Raw commit eaad4ad adds src/gateway/embeddings-http.ts:115 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: eaad4ad1be38; files: src/gateway/embeddings-http.ts)

PR surface

Source 0, Tests +16, Docs +2. Total +18 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 9 0
Tests 1 39 23 +16
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 50 32 +18

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Valid slash-containing embedding model IDs fail in a bounded HTTP integration workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-29T11:55:47.844Z sha 2882994 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T01:47:32.808Z sha 2882994 :: blocked before merge. :: [P2] Make the default-model regression exercise a failing override
  • reviewed 2026-09-30T02:09:26.120Z sha d42c87b :: blocked before merge. :: none
  • reviewed 2026-10-09T22:50:09.674Z sha 80c9550 :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 7:04 PM ET / 23:04 UTC (Revision 5).

@clawsweeper clawsweeper Bot added 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. and removed 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 30, 2026

@Ayushdevo Ayushdevo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the slash-model disambiguation. The new lookup keeps provider/model semantics for prefixes that resolve to a known embedding provider, while preserving slash-containing model IDs such as BAAI/bge-m3 for the configured provider. The tests cover both the configured-model path and the request-header override, plus the rejection of a different known provider. I don't see a blocker in this patch.

@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 30, 2026
Merge current main while preserving the contributor commits. Keep provider selection constrained to the configured provider, forward opaque model IDs intact, and reuse memory config normalization.

Co-authored-by: xialonglee <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 9, 2026
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 9, 2026
@steipete steipete self-assigned this Oct 10, 2026
@steipete
steipete merged commit b90a911 into openclaw:main Oct 10, 2026
135 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…#161170)

* fix(gateway): allow slash model ids in embeddings overrides

* test(gateway): set explicit slash model in embeddings regression

Co-authored-by: xialonglee <[email protected]>
@xialonglee
xialonglee deleted the fix/gap-embeddings-slash-model branch November 4, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants