diff --git a/litellm/llms/a2a/chat/transformation.py b/litellm/llms/a2a/chat/transformation.py index 5c993d20cca..d3827f971dc 100644 --- a/litellm/llms/a2a/chat/transformation.py +++ b/litellm/llms/a2a/chat/transformation.py @@ -51,8 +51,8 @@ class A2AConfig(BaseConfig): Returns: Tuple of (api_base, api_key, headers) with registry values filled in """ - # Extract agent name from model (e.g., "a2a/my-agent" -> "my-agent") - agent_name = model.split("/", 1)[1] if "/" in model else None + # get_llm_provider strips the "a2a/" prefix, so model is usually the bare agent name + agent_name = model.split("/", 1)[1] if "/" in model else model if not agent_name: return api_base, api_key, headers diff --git a/tests/test_litellm/llms/a2a/chat/test_a2a_chat_transformation.py b/tests/test_litellm/llms/a2a/chat/test_a2a_chat_transformation.py index de030f8ae2a..8471c1f148a 100644 --- a/tests/test_litellm/llms/a2a/chat/test_a2a_chat_transformation.py +++ b/tests/test_litellm/llms/a2a/chat/test_a2a_chat_transformation.py @@ -66,13 +66,17 @@ def registered_agent(): global_agent_registry.agent_list = original -def test_resolve_agent_config_applies_static_headers(registered_agent): +@pytest.mark.parametrize("model", ["a2a/static-headers-agent", "static-headers-agent"]) +def test_resolve_agent_config_applies_static_headers(registered_agent, model): """Regression for #32608: the /chat/completions bridge must forward an agent's - static_headers, consistent with the native /a2a/{agent_id} route.""" + static_headers, consistent with the native /a2a/{agent_id} route. + + get_llm_provider strips the "a2a/" prefix before dispatch, so the resolver + must find the agent whether the model still carries the prefix or not.""" registered_agent(static_headers={"x-api-key": "secret-value"}) - _, _, headers = A2AConfig.resolve_agent_config_from_registry( - model="a2a/static-headers-agent", + api_base, _, headers = A2AConfig.resolve_agent_config_from_registry( + model=model, api_base=None, api_key=None, headers=None, @@ -80,6 +84,7 @@ def test_resolve_agent_config_applies_static_headers(registered_agent): ) assert headers == {"x-api-key": "secret-value"} + assert api_base == "http://agent.example.com:9999" def test_static_headers_win_over_request_headers_case_insensitive(registered_agent):