Skip to content

fix(llm): match LiteLLM proxy model_info by litellm_params.model too - #3429

Merged
juanmichelini merged 5 commits into
mainfrom
fix/proxy-model-info-litellm-params
Jun 6, 2026
Merged

juanmichelini merged 5 commits into
mainfrom
fix/proxy-model-info-litellm-params

Conversation

@juanmichelini

@juanmichelini juanmichelini commented May 29, 2026 •

Copy link
Copy Markdown
Collaborator
  • A human has tested these changes.

Why

Even after All-Hands-AI/infra#1309 merged and deployed (which sets model_info.supports_vision: true on the claude-opus-4-8 proxy entry), the vision integration test is still skipped:

t08_image_file_viewing: ⊘ - This test requires a vision-capable LLM model.
Please use a model that supports image input.

See run #26608680950 on commit 45697f5.

Root cause

openhands.sdk.llm.utils.model_info._get_model_info_from_litellm_proxy only matched proxy entries by model_name:

current = next(
    (info for info in data
     if info["model_name"] == model.removeprefix("litellm_proxy/")),
    None,
)

Our LiteLLM proxy config registers the new model with a short public alias:

- model_name: "claude-opus-4-8"            # alias
  litellm_params:
    model: "anthropic/claude-opus-4-8"     # underlying provider id
  model_info:
    supports_vision: true

The SDK is configured with model = "litellm_proxy/anthropic/claude-opus-4-8". After stripping the litellm_proxy/ prefix it looks for model_name == "anthropic/claude-opus-4-8" — a miss. get_litellm_model_info then falls back to litellm.get_model_info("claude-opus-4-8").

  • For claude-opus-4-7 this fallback succeeds because LiteLLM upstream already knows the id, so the bug has been silently masked.
  • For claude-opus-4-8 LiteLLM upstream does not know the id yet, the fallback also returns None, LLM._model_info ends up None, and LLM._supports_vision() returns False. 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_info overrides set in proxy config are invisible to the SDK.

What

Extend the matcher in _get_model_info_from_litellm_proxy to also try litellm_params.model — the same field the proxy itself accepts for incoming requests:

stripped = model.removeprefix("litellm_proxy/")
current = next(
    (info for info in data
     if info.get("model_name") == stripped
     or info.get("litellm_params", {}).get("model") == stripped),
    None,
)

The original model_name match path is unchanged, so callers that address the proxy by its alias still hit the same entry. The new path only fires when model_name does not match — exactly today's silent-miss case.

Tests

New tests/sdk/llm/test_model_info_proxy_lookup.py covers:

  • test_lookup_matches_by_model_name_alias — backward-compat.
  • test_lookup_matches_by_litellm_params_model — the case that broke claude-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 through get_litellm_model_info, asserting supports_vision: true flows 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.py

Local results from this branch:

  • New tests: 4 passed.
  • Targeted regression sweep: 28 passed, 0 failed.
  • Pre-commit (ruff format/lint, pycodestyle, pyright, import-rule, tool-registration): all hooks passed.

After merge, re-running the Run Integration Tests vision claude-opus-4-8 workflow on main is expected to actually execute t08_image_file_viewing instead of skipping it.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Related

  • All-Hands-AI/infra#1305 — registered claude-opus-4-8 on the proxy
  • All-Hands-AI/infra#1309 — added model_info.supports_vision: true (correct on the proxy side, but invisible to the SDK without this fix)
  • Register claude-opus-4-8 in SDK model lists #3424 — SDK model registration

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

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:c4c20d2-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-c4c20d2-python \
  ghcr.io/openhands/agent-server:c4c20d2-python

All tags pushed for this build

ghcr.io/openhands/agent-server:c4c20d2-golang-amd64
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-golang-amd64
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-golang-amd64
ghcr.io/openhands/agent-server:c4c20d2-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:c4c20d2-golang-arm64
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-golang-arm64
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-golang-arm64
ghcr.io/openhands/agent-server:c4c20d2-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:c4c20d2-java-amd64
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-java-amd64
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-java-amd64
ghcr.io/openhands/agent-server:c4c20d2-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:c4c20d2-java-arm64
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-java-arm64
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-java-arm64
ghcr.io/openhands/agent-server:c4c20d2-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:c4c20d2-python-amd64
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-python-amd64
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-python-amd64
ghcr.io/openhands/agent-server:c4c20d2-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:c4c20d2-python-arm64
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-python-arm64
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-python-arm64
ghcr.io/openhands/agent-server:c4c20d2-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:c4c20d2-golang
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-golang
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-golang
ghcr.io/openhands/agent-server:c4c20d2-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:c4c20d2-java
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-java
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-java
ghcr.io/openhands/agent-server:c4c20d2-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:c4c20d2-python
ghcr.io/openhands/agent-server:c4c20d2ca663a0c08199f039ccfccc8be693abc3-python
ghcr.io/openhands/agent-server:fix-proxy-model-info-litellm-params-python
ghcr.io/openhands/agent-server:c4c20d2-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

  • Each variant tag (e.g., c4c20d2-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., c4c20d2-python-amd64) are also available if needed

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>
@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/llm/utils
   model_info.py53786%52–53, 66–70
TOTAL29353828771% 

@juanmichelini
juanmichelini marked this pull request as ready for review June 4, 2026 06:15

all-hands-bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 both model_name and litellm_params.model to 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_info validates 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 all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ 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 ⚠️ GitHub checks observed: 20 successful, 1 failing (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-alias
  • litellm_params.model: anthropic/openhands-qa-unregistered-vision-model-0604
  • model_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.py

Observed 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.py

Observed 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-tests is 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.

all-hands-bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 by litellm_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 all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ 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 ⚠️ At review time: 20 successful, 1 failing (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/check failing; 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.

@juanmichelini
juanmichelini merged commit 2589e5d into main Jun 6, 2026
32 of 33 checks passed
@juanmichelini
juanmichelini deleted the fix/proxy-model-info-litellm-params branch June 6, 2026 04:50
pengzhang-create pushed a commit to Pyromind-Dynamics/software-agent-sdk that referenced this pull request Aug 13, 2026
…penHands#3429)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Engel Nyst <engel.nyst@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LiteLLM proxy model_info lookup misses when proxy uses short aliases (claude-opus-4-8 vision still off)

4 participants