[Bug] Unauthenticated model-info lookup still emits GET /v1/model/info when key is None

Open Beginner friendly
#5,454 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@daviskay75 is already working on this.

Since Oct 2, 2026.

  • #5456 by @daviskay75 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
api

Research direction

Start in openhands-sdk/openhands/sdk/llm/utils/model_info.py at _get_model_info_from_litellm_proxy and run the provided mocked repro. Confirm that keyless requests to recognized managed OpenHands proxy URLs make no HTTP call and use the existing local fallback, while keyed requests and generic proxies still attempt model-info lookup.

Written by the indexing model from the issue text.

Description

priority:low

[Bug] Unauthenticated model-info lookup still emits GET /v1/model/info when key is None

Follow-up to #4098 (closed by stale-bot, still present on main @ cc97bf23).

Current behavior

LLM._post_init() → _init_model_info_and_caps() → get_litellm_model_info() →
_get_model_info_from_litellm_proxy() (openhands-sdk/openhands/sdk/llm/utils/model_info.py):

headers = {}
if isinstance(secret_api_key, SecretStr):
    secret_api_key = secret_api_key.get_secret_value()
if secret_api_key:
    headers["Authorization"] = f"Bearer {secret_api_key}"

response = httpx.get(f"{base_url}/v1/model/info", headers=headers)

When no key is available, headers stays empty but the request is still sent. The
managed proxy answers 401, the SDK silently falls back to static LiteLLM
metadata — and every LLM construction / profile load / validation /
deserialization without credentials emits another unauthenticated request
(hourly lru_cache key per process, so fan-out still multiplies it).

Scope (per #4098)

Skip the request only when no key is available and the target is the managed
OpenHands proxy
(is_openhands_proxy_base_url, i.e. recognized
llm-proxy.app.all-hands.dev base URLs). Generic/custom proxies are unchanged:
an open proxy may legitimately serve model info without credentials, so those
lookups must still be attempted. None, empty, and blank keys all count as
keyless (none of them can authenticate).

Repro

from unittest.mock import patch, MagicMock
from openhands.sdk.llm.utils.model_info import _get_model_info_from_litellm_proxy

with patch("openhands.sdk.llm.utils.model_info.httpx.get") as m:
    m.return_value.json.return_value = {"data": []}
    _get_model_info_from_litellm_proxy(
        secret_api_key=None, base_url="https://llm-proxy.app.all-hands.dev",
        model="litellm_proxy/some-model", cache_key=1,
    )
    assert m.call_count == 0  # FAILS: called once with headers={}

Proposed fix

Skip the request under the scope above and fall through to the existing local
fallbacks (get_model_info variants in get_litellm_model_info). Keyed
requests — including invalid keys, whose real 401 stays visible — unchanged.

PR incoming, referencing this issue.

Dominant language
Python
Stars
1.4k
Forks
797
Avg merge
1d 17h
Merged PRs (30d)
354

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenHands/software-agent-sdk

All issues in OpenHands/software-agent-sdk

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.