Repository navigation
fix(llm): match LiteLLM proxy model_info by litellm_params.model too - #3429
Conversation
The proxy /v1/model/info matcher only checked `model_name` (the public alias). When a proxy config exposes a model under a short alias (`claude-opus-4-8`) for a provider id (`anthropic/claude-opus-4-8`), clients addressing the model by its provider id (the typical SDK setup of `litellm_proxy/anthropic/claude-opus-4-8`) missed the entry. When that happens, `get_litellm_model_info` falls back to `litellm.get_model_info` on the upstream catalog. For models LiteLLM already knows the fallback succeeded and hid the bug. For new model ids LiteLLM has not yet registered (Claude Opus 4.8 today), the fallback also returns None, `_model_info` ends up None, and `_supports_vision` returns False — so `model_info.supports_vision: true` overrides set on the proxy never reach the SDK and t08_image_file_viewing is skipped. Extend the matcher to also check `litellm_params.model`, mirroring how the proxy itself accepts incoming requests. The existing alias-match path is unchanged, so this is backward compatible. Adds dedicated unit tests for both match paths (alias and provider id), the negative case, and the end-to-end `get_litellm_model_info` path. Fixes #3428 Co-authored-by: openhands <openhands@all-hands.dev>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
PR Review: fix(llm): match LiteLLM proxy model_info by litellm_params.model too
Changes summary: 2 files changed, 121 additions, 1 deletion
Assessment
This PR is well-structured and clean. It addresses a real issue where the LiteLLM proxy model lookup would miss entries when the SDK is configured with the provider-prefixed model ID (e.g., anthropic/claude-opus-4-8) instead of the proxy's public alias (e.g., claude-opus-4-8).
Changes review
openhands-sdk/openhands/sdk/llm/utils/model_info.py (+10, -1)
- ✅ Good: Extracts
stripped = model.removeprefix("litellm_proxy/")to avoid code duplication between the two match conditions - ✅ Good: Uses
.get()safely on bothmodel_nameandlitellm_params.modelto avoid KeyErrors - ✅ Good: Includes clear inline comments explaining the motivation for the change
- 🟢 Minor (acceptable): The comment mentions "clients that address the model by its provider id" - this is accurate and the fix handles it correctly
tests/sdk/llm/test_model_info_proxy_lookup.py (+111, -0)
- ✅ Excellent: Comprehensive test coverage with 4 test cases
- ✅ Good: Tests cover both existing behavior (alias match) and new behavior (provider-id match)
- ✅ Good: Includes edge cases (unknown model returns None)
- ✅ Good: End-to-end test for
get_litellm_model_infovalidates the full flow - ✅ Good: Uses
cache_clear()to avoid cache interference between tests
Conclusion
This is a low-risk, high-value fix. The change is minimal, targeted, and well-tested. No breaking changes to existing functionality—only adds a secondary matching path for provider-prefixed model IDs.
🟢 Recommendation: Approve (once ready for review - currently marked as draft)
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
⚠️ QA Report: PASS WITH ISSUES
Functional behavior claimed by the PR was verified with a local LiteLLM-proxy-compatible /v1/model/info endpoint; CI currently has one failing check.
Does this PR achieve its stated goal?
Yes. The goal was to make SDK LiteLLM proxy model-info lookup honor proxy entries where the requested provider id matches litellm_params.model even when model_name is a shorter alias. On the base branch, the same real SDK call against a local proxy response missed the provider-id entry (provider_id_lookup: null) and reported llm_provider_id_supports_vision: false; on this PR branch, it returned the proxy model_info override and reported llm_provider_id_supports_vision: true. Alias lookup still worked and an unknown provider id still returned null.
| Phase | Result |
|---|---|
| Environment Setup | ✅ uv run python created the project environment and imported openhands.sdk successfully. |
| CI Status | Run tests/sdk-tests), 6 pending, 3 skipped. I did not rerun tests. |
| Functional Verification | ✅ Before/after SDK execution verified the proxy alias/provider-id behavior. |
Functional Verification
Test 1: Provider-id lookup against LiteLLM proxy model info
I used a temporary script that starts a local HTTP server responding to GET /v1/model/info with a LiteLLM-proxy-style entry:
model_name:openhands-qa-vision-aliaslitellm_params.model:anthropic/openhands-qa-unregistered-vision-model-0604model_info.supports_vision:true
The script then calls the SDK with model="litellm_proxy/anthropic/openhands-qa-unregistered-vision-model-0604" and also checks alias and unknown-model behavior.
Step 1 — Reproduce / establish baseline without the fix:
Ran on origin/main:
git switch --detach origin/main
OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_litellm_proxy_model_info.pyObserved relevant output:
{
"alias_lookup": {"qa_marker": "provider-id-match", "supports_vision": true},
"provider_id_lookup": null,
"llm_provider_id_supports_vision": false,
"unknown_lookup": null
}This confirms the bug: addressing the proxy model by provider id missed the proxy's model_info entry, so the SDK treated the configured LLM as not vision-capable even though the proxy advertised supports_vision: true.
Step 2 — Apply the PR's changes:
Checked out fix/proxy-model-info-litellm-params at 8686b2c94be882c6b242fe130b69c1298574d8a4.
Step 3 — Re-run with the fix in place:
Ran the same SDK scenario:
OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_litellm_proxy_model_info.pyObserved relevant output:
{
"alias_lookup": {"qa_marker": "provider-id-match", "supports_vision": true},
"provider_id_lookup": {"qa_marker": "provider-id-match", "supports_vision": true},
"llm_provider_id_supports_vision": true,
"unknown_lookup": null
}This shows the fix works: the same provider-id configuration now receives the proxy override and the SDK's LLM vision gate reports true. The side checks also show backward-compatible alias lookup still succeeds and an unrelated unknown model still does not match.
Issues Found
- 🟠 Issue: CI is not fully green at observation time:
Run tests/sdk-testsis failing and six checks are still pending. I did not inspect or rerun tests per QA instructions.
This review was created by an AI agent (OpenHands) on behalf of the user.
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Code Review
🟢 Good taste — Clean, minimal fix that solves a real problem with an elegant solution.
Analysis
Pragmatism ✅
This fix addresses a genuine production issue: model_info overrides (e.g., supports_vision: true for models LiteLLM doesn't yet know upstream) were silently failing when the SDK was configured with the provider-prefixed ID instead of the proxy's short alias.
Data Structures & Logic ✅
The change is minimal — an or condition in a generator expression. Extracting stripped = model.removeprefix("litellm_proxy/") once and reusing it is good efficiency. Using .get() with safe defaults handles cases where litellm_params might be missing.
Backward Compatibility ✅
This is purely additive. The existing model_name match is preserved; the litellm_params.model match is an additional fallback. No existing behavior is broken.
Tests ✅
Good test coverage:
- Tests both existing behavior (matching by
model_name) and new behavior (matching bylitellm_params.model) - Covers the edge case of unknown models returning
None - End-to-end test via
get_litellm_model_info - Proper cache clearing between tests
[RISK ASSESSMENT]
- [Overall PR]
⚠️ Risk Assessment: 🟢 LOW
Minimal change, contained to one function, well-tested, backward-compatible. No security concerns, no new dependencies.
VERDICT:
✅ Worth merging — Core logic is sound, well-tested, minimal and focused change.
KEY INSIGHT:
The fix is exactly one or condition added to an existing generator expression — the simplest possible solution that solves the problem without introducing complexity.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
⚠️ QA Report: PASS WITH ISSUES
Functionally, the PR fixes LiteLLM proxy model_info lookup for provider-prefixed models while preserving alias lookup; CI was not fully green at review time.
Does this PR achieve its stated goal?
Yes. I exercised the SDK against a local HTTP server that behaves like a LiteLLM proxy /v1/model/info endpoint where model_name is a short alias and litellm_params.model is the provider-prefixed model id. On origin/main, configuring LLM(model="litellm_proxy/anthropic/qa-proxy-only-vision-model") missed the proxy override and reported provider_llm_supports_vision: false; on PR commit cc49e6d, the same real SDK call read the proxy override and reported provider_llm_supports_vision: true. Alias-based lookup stayed true in both runs.
| Phase | Result |
|---|---|
| Environment Setup | ✅ uv run created/used the project environment and imported the SDK successfully. |
| CI Status | Deprecation deadlines/check), 2 skipped, 8 pending. I did not rerun tests. |
| Functional Verification | ✅ Before/after runtime check confirms provider-id proxy matching now reaches supports_vision: true, and alias lookup still works. |
Functional Verification
Test 1: LiteLLM proxy alias vs provider-prefixed model lookup
Step 1 — Reproduce / establish baseline without the fix:
Ran git fetch origin main fix/proxy-model-info-litellm-params && git switch --detach origin/main && uv run python /tmp/qa_litellm_proxy_model_info.py.
The script starts a local HTTP server serving this LiteLLM-style model info shape: model_name: qa-alias-model-vision, litellm_params.model: anthropic/qa-proxy-only-vision-model, and model_info.supports_vision: true. It then imports the SDK, calls get_litellm_model_info(...), and instantiates LLM(...) for both the provider-prefixed id and the alias.
Relevant output:
{
"alias_llm_supports_vision": true,
"alias_lookup": {
"qa_marker": "proxy-model-info-override",
"supports_vision": true
},
"provider_llm_supports_vision": false,
"provider_lookup": null,
"provider_model": "litellm_proxy/anthropic/qa-proxy-only-vision-model",
"proxy_requests": [
{"auth": "Bearer dummy-key", "path": "/v1/model/info"},
{"auth": "Bearer dummy-key", "path": "/v1/model/info"},
{"auth": "Bearer dummy-key", "path": "/v1/model/info"},
{"auth": "Bearer dummy-key", "path": "/v1/model/info"}
]
}This confirms the bug exists without the fix: the SDK did make real HTTP requests to /v1/model/info, alias lookup worked, but provider-prefixed lookup returned null, causing the configured LLM to report no vision support.
Step 2 — Apply the PR's changes:
Checked out PR commit cc49e6deeca9b50d72fc719459cbb0a799cc3230.
Step 3 — Re-run with the fix in place:
Ran git switch --detach cc49e6deeca9b50d72fc719459cbb0a799cc3230 && uv run python /tmp/qa_litellm_proxy_model_info.py.
Relevant output:
{
"alias_llm_supports_vision": true,
"alias_lookup": {
"qa_marker": "proxy-model-info-override",
"supports_vision": true
},
"provider_llm_supports_vision": true,
"provider_lookup": {
"qa_marker": "proxy-model-info-override",
"supports_vision": true
},
"provider_model": "litellm_proxy/anthropic/qa-proxy-only-vision-model",
"proxy_requests": [
{"auth": "Bearer dummy-key", "path": "/v1/model/info"},
{"auth": "Bearer dummy-key", "path": "/v1/model/info"},
{"auth": "Bearer dummy-key", "path": "/v1/model/info"},
{"auth": "Bearer dummy-key", "path": "/v1/model/info"}
]
}This confirms the fix works: the same provider-prefixed model now receives the proxy model_info override and the SDK reports vision support as true. The alias path remains true, so the original behavior is preserved.
Issues Found
- 🟡 CI status: Functional QA passed, but the PR was not fully green at review time (
Deprecation deadlines/checkfailing; 8 checks pending). No functional issues found in the changed behavior.
This QA review was generated by an AI agent (OpenHands) on behalf of the user.
Co-authored-by: Engel Nyst <engel.nyst@gmail.com>
…penHands#3429) Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Engel Nyst <engel.nyst@gmail.com>
Why
Even after All-Hands-AI/infra#1309 merged and deployed (which sets
model_info.supports_vision: trueon theclaude-opus-4-8proxy entry), the vision integration test is still skipped:See run #26608680950 on commit
45697f5.Root cause
openhands.sdk.llm.utils.model_info._get_model_info_from_litellm_proxyonly matched proxy entries bymodel_name:Our LiteLLM proxy config registers the new model with a short public alias:
The SDK is configured with
model = "litellm_proxy/anthropic/claude-opus-4-8". After stripping thelitellm_proxy/prefix it looks formodel_name == "anthropic/claude-opus-4-8"— a miss.get_litellm_model_infothen falls back tolitellm.get_model_info("claude-opus-4-8").claude-opus-4-7this fallback succeeds because LiteLLM upstream already knows the id, so the bug has been silently masked.claude-opus-4-8LiteLLM upstream does not know the id yet, the fallback also returnsNone,LLM._model_infoends upNone, andLLM._supports_vision()returnsFalse. The infra override is never read.This is a general bug, not specific to one model: any time the proxy uses an alias that differs from the provider id the SDK uses (the recommended LiteLLM pattern),
model_infooverrides set in proxy config are invisible to the SDK.What
Extend the matcher in
_get_model_info_from_litellm_proxyto also trylitellm_params.model— the same field the proxy itself accepts for incoming requests:The original
model_namematch path is unchanged, so callers that address the proxy by its alias still hit the same entry. The new path only fires whenmodel_namedoes not match — exactly today's silent-miss case.Tests
New
tests/sdk/llm/test_model_info_proxy_lookup.pycovers:test_lookup_matches_by_model_name_alias— backward-compat.test_lookup_matches_by_litellm_params_model— the case that brokeclaude-opus-4-8.test_lookup_returns_none_for_unknown_model— negative.test_get_litellm_model_info_uses_proxy_match_for_provider_prefixed_id— end-to-end throughget_litellm_model_info, assertingsupports_vision: trueflows through.Issue Number
Fixes #3428
How to Test
uv run pytest tests/sdk/llm/test_model_info_proxy_lookup.py -v uv run pytest tests/sdk/llm/ -k "model_info or vision or supports_vision" -q uv run pre-commit run --files \ openhands-sdk/openhands/sdk/llm/utils/model_info.py \ tests/sdk/llm/test_model_info_proxy_lookup.pyLocal results from this branch:
After merge, re-running the
Run Integration Tests vision claude-opus-4-8workflow onmainis expected to actually executet08_image_file_viewinginstead of skipping it.Type
Related
claude-opus-4-8on the proxymodel_info.supports_vision: true(correct on the proxy side, but invisible to the SDK without this fix)This PR was opened by an AI agent (OpenHands) on behalf of @juanmichelini.
@juanmichelini can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:c4c20d2-pythonRun
All tags pushed for this build
About Multi-Architecture Support
c4c20d2-python) is a multi-arch manifest supporting both amd64 and arm64c4c20d2-python-amd64) are also available if needed