Skip to content

feat(sdk): consume proxy-advertised request-parameter capabilities - #5502

Merged
neubig merged 2 commits into
mainfrom
feat/proxy-advertised-request-params
Oct 29, 2026
Merged

neubig merged 2 commits into
mainfrom
feat/proxy-advertised-request-params

Conversation

@neubig

@neubig neubig commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

I read the code and am satisfied by the agent's testing. Merging in.


AGENT:

Why

_get_model_info_from_litellm_proxy() returned only current["model_info"]. That dropped litellm_params.allowed_openai_params, which is how a LiteLLM proxy deployment declares which extra request params it forwards upstream. Because of this, the SDK could not learn from proxy metadata that an alias accepts reasoning_effort. It had to rely on the generic supports_reasoning flag, the static LiteLLM registry, or model-name lists.

Summary

  • Producer (model_info.py): when a /v1/model/info entry matches, copy allowed_openai_params into the returned model_info. If several deployments match the alias, keep only the params that all of them allow, since the proxy can route to any of them. Non-list values and non-string items are ignored. Nothing else from litellm_params is kept.
  • Consumer (model_features.py): an advertised param can enable only the capability that is that request param:
    • reasoning_effort → supports_reasoning_effort
    • prompt_cache_key → supports_prompt_cache_key
    • prompt_cache_retention → supports_prompt_cache_retention
  • Precedence: explicit capability_overrides win, then an advertised param, then existing metadata, then fallbacks. A param missing from the list is not treated as a denial, because LiteLLM uses the list only to extend the provider's native params. Vision, prompt caching (cache_control), thinking mode, and other capabilities are never derived from the list.
  • No model or alias names are hard-coded. Discovery stays optional. Auth, timeout, error, cache and fallback paths are unchanged.

Issue Number

Fixes #5499

How to Test

Base: 7999acfadc0a163186f5a8025ffda0de8e351c34 (main).
Head: 45259c484a9b37d79c73a10cb457b076a9395fb3 (code and tests) + 88249e4 (.pr/ evidence only).

Reproducer

.pr/proxy-request-params/repro.py calls /v1/model/info with a Bearer key and builds LLM(model="litellm_proxy/deepseek-v4.1-flash", reasoning_effort="low"). It then prints only:

  • the HTTP status and the alias's allowed_openai_params / supports_reasoning
  • the SDK's model_info
  • the resolved features
  • the ModelFeatures fields that the advertised params change
  • whether reasoning_effort appears in the chat request

It never prints the credential or any other catalog entry. --fixture serves the redacted entry quoted in #5499 from an in-process proxy that returns 401 without the right Bearer key.

Before (base source; full log: before.txt):

$ uv run python .pr/proxy-request-params/repro.py --fixture
credential supplied: True
proxy /v1/model/info: {"http_status": 200, "entry": {"model_name": "deepseek-v4.1-flash", "litellm_params.allowed_openai_params": ["reasoning_effort"], "model_info.supports_reasoning": true}}
SDK model_info found: True
SDK model_info.allowed_openai_params: None
SDK features: {"supports_reasoning_effort": true, "supports_prompt_cache_key": true, "supports_vision": false}
supports_reasoning_effort from advertised request params alone: False
features changed by advertised params [without, with]: {}
chat request reasoning_effort: low

After (head 45259c4; full log: after.txt):

$ uv run python .pr/proxy-request-params/repro.py --fixture
credential supplied: True
proxy /v1/model/info: {"http_status": 200, "entry": {"model_name": "deepseek-v4.1-flash", "litellm_params.allowed_openai_params": ["reasoning_effort"], "model_info.supports_reasoning": true}}
SDK model_info found: True
SDK model_info.allowed_openai_params: ['reasoning_effort']
SDK features: {"supports_reasoning_effort": true, "supports_prompt_cache_key": true, "supports_vision": false}
supports_reasoning_effort from advertised request params alone: True
features changed by advertised params [without, with]: {'supports_reasoning_effort': [False, True]}
chat request reasoning_effort: low

Reading the output:

  • Before: the advertised param is lost. supports_reasoning_effort is true only because of the generic supports_reasoning flag (the concern in SDK sends unsupported reasoning_effort to MiniMax M3 #4934).
  • After: the param is kept and enables supports_reasoning_effort on its own. It changes no other ModelFeatures field.
  • supports_prompt_cache_key: true appears both before and after, and does not come from this change. The [Bug]: Native LLM spans record gen_ai.usage.cost = 0.0 for custom litellm_proxy/* model names #4816 alias-pricing registration maps the alias to the underlying openrouter/… entry, and LiteLLM's OpenRouter param set includes prompt_cache_key. The "features changed" line shows the advertised params do not affect it.
  • With --fixture --no-key (401), output is identical before and after: no model_info, every capability false, and no reasoning_effort sent.

Tests

New tests in tests/sdk/llm/test_model_info_proxy_lookup.py run against a real local HTTP /v1/model/info server and go through the actual LLM → get_litellm_model_info → get_features → select_chat_options path. New tests in tests/sdk/llm/test_model_features.py cover get_features directly. They use an alias the LiteLLM registry does not know (acme-reasoner-7), so the proxy is the only source of the capability. Coverage:

  • authenticated and authless proxies
  • intersection across deployments
  • malformed list values
  • missing key, 401, 500 with a non-JSON body, invalid JSON, and malformed data, all falling back to existing behavior
  • the hourly cache
  • precedence: overrides > advertised param > generic supports_reasoning
  • negative cases: advertising reasoning_effort enables no other ModelFeatures field (prompt_cache_key, prompt_cache, vision, …), and unmapped names such as supports_vision/image_url, a bare string, or non-strings change nothing
$ uv run pytest tests/sdk/llm/test_model_info_proxy_lookup.py tests/sdk/llm/test_model_features.py -q
base source + new tests: 9 failed, 232 passed   (all 9 are the new positive tests)
head:                    241 passed
$ uv run pytest tests/sdk/llm -q -n 8                     -> 1184 passed
$ uv run pre-commit run --files <4 changed files + repro>  -> ruff, pycodestyle, pyright, import rules: Passed
$ uv run pytest tests/sdk tests/cross -q -n 8              -> 7341 passed, 10 failed, 1 error (see Notes)

Video/Screenshots

Not applicable. This is SDK capability resolution with no UI change. Evidence is the reproducer output above.

Design Doc

Not applicable. The change is two small functions plus one precedence rule.

Type

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

Notes

  • Is allowed_openai_params a stable LiteLLM contract? Only partly.
  • Key scoping: the cache is still keyed by (API key, base URL, model, hour). Only the list of param names is retained.
  • Side effect: when an advertised reasoning_effort enables supports_reasoning_effort, the existing chat-options rule also drops sampling params for that model unless supports_sampling_params says otherwise. This is the same rule that already applies to every reasoning-effort model.
  • Live authenticated run not done. LLM_API_KEY was not present in this sandbox. The unauthenticated live call returns 401 and falls back exactly as on base (included in before.txt/after.txt). Run LLM_API_KEY=... uv run python .pr/proxy-request-params/repro.py --base-url https://llm-proxy.app.all-hands.dev to confirm against the managed proxy. The fixture serves the exact redacted entry from Define and consume proxy-advertised request-parameter capabilities #5499.
  • Broad-suite failures are environmental:
    • The 6 tests/sdk failures (hooks async, FIFO fairness, import timing) pass when rerun serially on this branch (75 passed). They are timing-sensitive under -n 8.
    • The tests/cross failures came from the sandbox's runtime env vars leaking into the in-process agent-server. With a clean env, tests/cross/test_hello_world.py and test_remote_conversation_live_server.py give 26 passed, 1 skipped.
  • PR description check: Define and consume proxy-advertised request-parameter capabilities #5499 currently lacks the ready-for-dev label, so that check will fail once this leaves draft until a maintainer triages the issue.
  • Originating conversation: https://app.beta.staging.all-hands-testing.dev/conversations/c587410bdd70408caa4794451d1ba92e

This PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• 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-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime 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:88249e4-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:88249e4-golang-amd64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-golang-amd64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-golang-amd64
ghcr.io/openhands/agent-server:88249e4-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:88249e4-golang-arm64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-golang-arm64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-golang-arm64
ghcr.io/openhands/agent-server:88249e4-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:88249e4-java-amd64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-java-amd64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-java-amd64
ghcr.io/openhands/agent-server:88249e4-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:88249e4-java-arm64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-java-arm64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-java-arm64
ghcr.io/openhands/agent-server:88249e4-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:88249e4-python-amd64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-amd64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-amd64
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-amd64
ghcr.io/openhands/agent-server:88249e4-python-arm64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-arm64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-arm64
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-arm64
ghcr.io/openhands/agent-server:88249e4-python-minimal-amd64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-minimal-amd64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-minimal-amd64
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:88249e4-python-minimal-arm64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-minimal-arm64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-minimal-arm64
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:88249e4-python-slim-amd64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-slim-amd64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-slim-amd64
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:88249e4-python-slim-arm64
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-slim-arm64
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-slim-arm64
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:88249e4-golang
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-golang
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-golang
ghcr.io/openhands/agent-server:88249e4-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:88249e4-java
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-java
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-java
ghcr.io/openhands/agent-server:88249e4-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:88249e4-python-minimal
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-minimal
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-minimal
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-minimal
ghcr.io/openhands/agent-server:88249e4-python-slim
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python-slim
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python-slim
ghcr.io/openhands/agent-server:88249e4-python-node-runtime-slim
ghcr.io/openhands/agent-server:88249e4-python
ghcr.io/openhands/agent-server:88249e424ba5bd718f8bf870c35990a0cf133491-python
ghcr.io/openhands/agent-server:feat-proxy-advertised-request-params-python
ghcr.io/openhands/agent-server:88249e4-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 88249e4-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., 88249e4-python-amd64) are also available if needed

Keep litellm_params.allowed_openai_params from the matching LiteLLM proxy
/v1/model/info entries (intersected across deployments) in the returned
model_info, and let an advertised param enable exactly the capability
that is that request param: reasoning_effort, prompt_cache_key, or
prompt_cache_retention. Explicit capability overrides still win; absence
from the list is not treated as a denial, so existing fallbacks are
unchanged.

Fixes #5499

Co-authored-by: openhands <openhands@all-hands.dev>
Temporary PR artifacts under .pr/; removed on approval.

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🧹 PR Artifact Cleanup Queued

The .pr/ directory reached main after merge. A cleanup PR has been opened or updated: #6304

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/llm/utils
   model_features.py171299%41, 419
   model_info.py106298%85–86
TOTAL463741301672% 

@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.

This review was posted by an AI agent (OpenHands).

Scope: In scope. The change lives entirely in openhands-sdk/openhands/sdk/llm/utils/ (capability resolution for LiteLLM proxy models), which this repository owns. No model or provider names are hard-coded, and discovery stays optional, matching the non-goals in #5499.

Verification on head 88249e4:

  • Current-head CI is green (sdk-tests, tools-tests, agent-server-tests, cross-tests, windows-tests, pre-commit, security, and all build/publish checks).
  • uv run pytest tests/sdk/llm/test_model_info_proxy_lookup.py tests/sdk/llm/test_model_features.py -q -> 238 passed, 3 failed. The 3 failures (test_reasoning_effort_support for openrouter/moonshotai/kimi-k2.5, openrouter/moonshotai/kimi-k2-thinking, openrouter/deepseek/deepseek-r1) also fail on the PR's merge-base 7999acfa in this environment; they are pre-existing route-dependent expectations, not a regression from this PR. Current main has already rewritten those cases to follow LiteLLM's live supported_openai_params (#4877 follow-up), so merging an updated branch picks up the corrected test.
  • Traced the full path: litellm_params.allowed_openai_params -> intersection across matching deployments -> model_info -> get_features via _resolved_bool -> select_chat_options. Overrides still win; the advertised-param check only affects the three request-param capabilities, so vision/prompt-cache/thinking cannot be enabled through it (negative tests assert this).
  • Compatibility: the new allowed_openai_params key lands in LLM._model_info, a private attribute that is not serialized or persisted; _register_proxy_alias_pricing copies only _PRICING_FIELDS, so nothing leaks into model_cost. Malformed litellm_params/param values degrade to absent, and the existing try/except fallback path is unchanged.

Acceptance criteria (#5499): all addressed - authoritative metadata without hardcoding, safe degradation on 401/500/invalid-JSON/malformed payloads (tested against a real local HTTP server through the actual LLM -> features -> chat-options path), no unrelated capability enablement, and documentation of the field's contract status. The issue now carries ready-for-dev.

Non-blocking notes for the maintainer:

  1. Upstream LiteLLM issue not yet filed: the drafted issue exists at .pr/proxy-request-params/litellm-upstream-issue.md, but filing against BerriAI/litellm returned 403 for the bot token. A maintainer needs to open it and link it, completing the final acceptance criterion.
  2. Live authenticated proxy run not performed: evidence uses a faithful fixture proxy (real HTTP, Bearer auth, the exact redacted entry from #5499) plus the unauthenticated live 401 run; the limitation is disclosed with the exact command (LLM_API_KEY=... uv run python .pr/proxy-request-params/repro.py --base-url https://llm-proxy.app.all-hands.dev). Worth a lightweight confirmation against the managed proxy before or shortly after merge.
  3. Branch age: the PR is based on 7999acfa; main has since touched model_features.py (no conflicts per GitHub, mergeable: true). Updating the branch before merge will also inherit main's rewritten route-following reasoning-effort tests.

No material correctness, security, or compatibility findings on the current head.

✅ APPROVED

@neubig
neubig marked this pull request as ready for review October 29, 2026 04:13
@neubig
neubig merged commit e88e6c7 into main Oct 29, 2026
56 of 57 checks passed
@neubig
neubig deleted the feat/proxy-advertised-request-params branch October 29, 2026 19:11
neubig pushed a commit that referenced this pull request Oct 29, 2026
Resolve llm capability conflicts additively: keep this PR's
consolidated capability resolver and provenance, graft main's
proxy-advertised request-param support (#5502, allowed_openai_params)
on top, and union-merge the proxy lookup / model features tests.
Advertised params enable exactly their capability; generic
supports_reasoning alone still does not authorize reasoning_effort
under this PR's resolver.

Co-authored-by: openhands <openhands@all-hands.dev>
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.

Define and consume proxy-advertised request-parameter capabilities

3 participants