Skip to content

fix: LiteLLM model discovery fails with 404 when baseUrl ends in /v1 - #149472

Merged
obviyus merged 3 commits into
openclaw:mainfrom
masatohoshino:fix/index-97df29
Sep 16, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
masatohoshino:fix/index-97df29

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #149471

What Problem This Solves

LiteLLM discovery appends /v1/v1/models when the proxy base already ends in /v1, as documented for remote onboarding.

Why This Change Was Made

The LiteLLM catalog hook alone selects the relative endpoint: models for versioned bases, v1/models otherwise. The shared URL join stays unchanged; no state writer is added. index.ts grows by 9 lines for this selection.
Growth accepted under the owner's standing acceptance (2026-09-15).

User Impact

Versioned proxy URLs reach the supported model-list endpoint without changing inference URLs.

Evidence

After non-interactive onboarding, with an explicit synthetic provider key and empty configured rows:
openclaw models list --provider litellm --refresh --json

  • Before: one GET /v1/v1/models → 404.
  • After: one GET /v1/models → 200.
  • Registered discovery returns the proxy row and reports ready to the shared dispatcher.
  • Unversioned, trailing-slash, prefixed and mixed-case-key controls pass. Inference request URLs remain unchanged.

These captures use a disposable HTTP proxy. Follow-up: onboarding alone made no discovery request; the request comparison uses the explicit-key setup above. Successful discovery still displayed zero CLI rows, and the reported warning did not reproduce. These separate setup and display problems remain unresolved.

Compatibility

No configuration, SDK or shared transport contract changes.

Consumers

LiteLLM live discovery uses the existing shared catalog dispatcher.

Invalidation

Existing endpoint and credential cache keys and refresh behavior remain in use.

Tests

20 LiteLLM tests and 4 MiniMax sibling tests pass on the merged source. Registered-hook HTTP captures confirm returned rows and outcomes.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 10:45 PM ET / September 16, 2026, 02:45 UTC (Revision 2).

ClawSweeper review

What this changes

The LiteLLM plugin selects the model-discovery path according to whether the configured proxy URL already ends in /v1, with regression coverage for supported URL forms.

Merge readiness

✅ Ready for maintainer review

Keep open: the endpoint defect remains on current main and in v2026.9.4. This focused repair has relevant HTTP proof and no actionable correctness findings.

Priority: P2
Reviewed head: 93c98b0030e4f02908f901947fecea2f1da84751

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful transport-boundary proof, meaningful regression cases, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The recorded CLI refresh and registered LiteLLM discovery use a disposable HTTP proxy and show the changed request recovering from 404 to 200 with returned rows and a ready outcome. This proves endpoint acquisition; it does not establish successful onboarding discovery or CLI row publication.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The recorded CLI refresh and registered LiteLLM discovery use a disposable HTTP proxy and show the changed request recovering from 404 to 200 with returned rows and a ready outcome. This proves endpoint acquisition; it does not establish successful onboarding discovery or CLI row publication.
Evidence reviewed 9 items Current-main defect: Fetched main still unconditionally selects v1/models. The shared endpoint builder trims slashes and concatenates the path, producing /v1/v1/models for a versioned base.
Latest-release check: v2026.9.4 retains both the unconditional LiteLLM endpoint and the concatenating shared URL builder; the proposed fix is not present in that release.
Documented configuration: Remote non-interactive onboarding explicitly documents a proxy base ending in /v1, establishing the configuration this repair supports.
Findings None None.
Security None None.

How this fits together

OpenClaw’s LiteLLM plugin supplies model discovery with the configured proxy URL and credentials. The shared catalog transport requests model rows and returns discovery outcomes to the catalog dispatcher.

flowchart LR
  A[Configured proxy URL] --> B[LiteLLM discovery hook]
  B --> C{Base ends in v1?}
  C -->|Yes| D[Append models]
  C -->|No| E[Append v1/models]
  D --> F[Shared HTTP catalog transport]
  E --> F
  F --> G[Model rows and discovery outcome]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +9, Tests +66. Total +75 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 5 +9
Tests 1 68 2 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 82 7 +75

Review metrics

None.

Technical review

Best possible solution:

Keep endpoint selection in the LiteLLM plugin while preserving configured inference URLs and the shared transport, authentication, and cache owners.

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

Yes: current source deterministically appends v1/models to a configured /v1 base, and the supplied HTTP capture corroborates that failure. This review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes: the existing plugin hook can choose the correct relative endpoint without changing shared URL semantics, public APIs, or stored configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs model discovery for versioned LiteLLM proxy URLs; the reported inference workflow remains functional.
  • 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 (logs): The recorded CLI refresh and registered LiteLLM discovery use a disposable HTTP proxy and show the changed request recovering from 404 to 200 with returned rows and a ready outcome. This proves endpoint acquisition; it does not establish successful onboarding discovery or CLI row publication.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded CLI refresh and registered LiteLLM discovery use a disposable HTTP proxy and show the changed request recovering from 404 to 200 with returned rows and a ready outcome. This proves endpoint acquisition; it does not establish successful onboarding discovery or CLI row publication.

Evidence

What I checked:

  • Current-main defect: Fetched main still unconditionally selects v1/models. The shared endpoint builder trims slashes and concatenates the path, producing /v1/v1/models for a versioned base. (extensions/litellm/index.ts:105, e853a4b9012d)
  • Latest-release check: v2026.9.4 retains both the unconditional LiteLLM endpoint and the concatenating shared URL builder; the proposed fix is not present in that release. (src/plugin-sdk/provider-catalog-live-runtime.ts:215, 3a9d69db306c)
  • Documented configuration: Remote non-interactive onboarding explicitly documents a proxy base ending in /v1, establishing the configuration this repair supports. Public docs: docs/providers/litellm.md. (docs/providers/litellm.md:24, 93c98b0030e4)
  • Introduced repair and regression coverage: The complete introduced delta changes only LiteLLM endpoint selection and its tests. Five registered-provider cases cover default, unversioned, versioned, prefixed/trailing-slash, and mixed-case-key configurations, asserting request URLs, returned rows, and ready outcomes. The existing shared lookup uses the same first normalized provider-key match. (extensions/litellm/index.ts:103, 93c98b0030e4)
  • Recorded HTTP behavior proof: The supplied complete PR body records models-list refresh against a disposable HTTP proxy with an explicit synthetic key and empty configured rows: before, GET /v1/v1/models returned 404; after, GET /v1/models returned 200. Registered discovery returned the proxy row and ready outcome. The body explicitly limits this evidence: onboarding alone made no discovery request, CLI output still showed zero rows, and the originally reported warning was not reproduced. Captured context sourceRevision: d1bebf051e67a67cf4a11a92ab56ea351310a1457ee97539780d9522d7ae15f1. (93c98b0030e4)
  • Re-review continuity: The two affected files are unchanged from the previously reviewed head. The supplied completed review has no findings or published rank-up moves; the new head incorporates main without changing this repair. (93c98b0030e4)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (1 earlier review cycle)
  • reviewed 2026-09-15T23:00:38.369Z sha 3097b61 :: needs maintainer review before merge. :: none

@obviyus
obviyus marked this pull request as draft September 16, 2026 02:19
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-admin-merge
pr: 149472
head: 93c98b0
scope: owner-review

@obviyus
obviyus marked this pull request as ready for review September 16, 2026 02:39
@obviyus
obviyus merged commit b68264d into openclaw:main Sep 16, 2026
158 of 159 checks passed
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks @masatohoshino!

Proof: A proxy base ending in /v1 returns its model list through registered discovery. Unversioned and prefixed bases work, and inference request URLs stay unchanged.

  • Bug: Discovery appended a second /v1 to a versioned proxy base.
  • Fix: The plugin selects the relative discovery path for the configured base.
Before After
GET /v1/v1/models returns 404 One GET /v1/models returns 200

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…penclaw#149472)

Closes openclaw#149471

## What Problem This Solves
LiteLLM discovery appends `/v1/v1/models` when the proxy base already ends in `/v1`, as documented for remote onboarding.

## Why This Change Was Made
The LiteLLM catalog hook alone selects the relative endpoint: `models` for versioned bases, `v1/models` otherwise. The shared URL join stays unchanged; no state writer is added. `index.ts` grows by 9 lines for this selection.
Growth accepted under the owner's standing acceptance (2026-09-15).

## User Impact
Versioned proxy URLs reach the supported model-list endpoint without changing inference URLs.

## Evidence
After non-interactive onboarding, with an explicit synthetic provider key and empty configured rows:
`openclaw models list --provider litellm --refresh --json`

- Before: one `GET /v1/v1/models` → 404.
- After: one `GET /v1/models` → 200.
- Registered discovery returns the proxy row and reports `ready` to the shared dispatcher.
- Unversioned, trailing-slash, prefixed and mixed-case-key controls pass. Inference request URLs remain unchanged.

These captures use a disposable HTTP proxy. Follow-up: onboarding alone made no discovery request; the request comparison uses the explicit-key setup above. Successful discovery still displayed zero CLI rows, and the reported warning did not reproduce. These separate setup and display problems remain unresolved.

## Compatibility
No configuration, SDK or shared transport contract changes.

## Consumers
LiteLLM live discovery uses the existing shared catalog dispatcher.

## Invalidation
Existing endpoint and credential cache keys and refresh behavior remain in use.

## Tests
20 LiteLLM tests and 4 MiniMax sibling tests pass on the merged source. Registered-hook HTTP captures confirm returned rows and outcomes.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Sep 16, 2026
)

Related: #149472

## What Problem This Solves

Without a Gateway, `models list --refresh` could exit with no discovered rows after a successful proxy response.

## Why This Change Was Made

The decision `whether refresh can outlive its caller` is made by exactly one mechanism at `src/agents/prepared-model-runtime.catalog-access.ts:658`; this state has one writer. Gateway refresh keeps its bounded wait. `catalog-access.ts` +5 lines; `build.ts` -1.

Growth accepted under the owner's standing acceptance (2026-09-15).

## User Impact

The command prints completed discovery instead of silently returning an earlier catalog.

## Evidence

`openclaw models list --provider litellm --refresh --json`: before, one GET `/v1/models` returned 200 but JSON had zero rows; after, one GET returned 200 and JSON listed the returned row. Twenty CLI tests and the Gateway pending control pass after merging main. Authored and unrelated provider JSON is byte-identical; failures warn.

## Compatibility

No JSON, SDK, or configuration change. The separate onboarding seed restriction needs its follow-up fix.

## Consumers

Standalone catalog refresh callers wait for completion. Gateway and ordinary reads keep existing behavior.

## Invalidation

Existing refresh, discovery deadlines, and owner replacement rules remain in place.

## Tests

Held discovery fails with the old behavior and passes with the fix. The existing Gateway control still returns pending before discovery completes.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…claw#149752)

Related: openclaw#149472

## What Problem This Solves

Without a Gateway, `models list --refresh` could exit with no discovered rows after a successful proxy response.

## Why This Change Was Made

The decision `whether refresh can outlive its caller` is made by exactly one mechanism at `src/agents/prepared-model-runtime.catalog-access.ts:658`; this state has one writer. Gateway refresh keeps its bounded wait. `catalog-access.ts` +5 lines; `build.ts` -1.

Growth accepted under the owner's standing acceptance (2026-09-15).

## User Impact

The command prints completed discovery instead of silently returning an earlier catalog.

## Evidence

`openclaw models list --provider litellm --refresh --json`: before, one GET `/v1/models` returned 200 but JSON had zero rows; after, one GET returned 200 and JSON listed the returned row. Twenty CLI tests and the Gateway pending control pass after merging main. Authored and unrelated provider JSON is byte-identical; failures warn.

## Compatibility

No JSON, SDK, or configuration change. The separate onboarding seed restriction needs its follow-up fix.

## Consumers

Standalone catalog refresh callers wait for completion. Gateway and ordinary reads keep existing behavior.

## Invalidation

Existing refresh, discovery deadlines, and owner replacement rules remain in place.

## Tests

Held discovery fails with the old behavior and passes with the fix. The existing Gateway control still returns pending before discovery completes.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: litellm 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: 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.

LiteLLM model discovery requests /v1/v1/models and fails when baseUrl ends in /v1

2 participants