This commit is contained in:
Mrunmayee Daware 2026-10-19 14:46:05 +02:00 • committed by GitHub
commit c8f0cd375e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 7 deletions

View file

@ -133,13 +133,13 @@ class A2AConfig(BaseConfig):
return api_base, api_key, headers
def get_supported_openai_params(self, model: str) -> list[str]:
"""Return list of supported OpenAI parameters"""
return [
"stream",
"temperature",
"max_tokens",
"top_p",
]
"""Return list of supported OpenAI parameters.
Only ``stream`` is forwarded (map_openai_params maps nothing else onto the
A2A JSON-RPC payload). Declaring sampling params as supported used to drop
them silently; leaving them unsupported makes callers fail loudly instead.
"""
return ["stream"]
def map_openai_params(
self,

View file

@ -226,3 +226,36 @@ def test_transform_response_reports_an_undecodable_body_as_an_agent_error():
assert exc_info.value.status_code == 502
assert exc_info.value.message.startswith("Failed to parse A2A response: ")
def test_get_supported_openai_params_declares_only_stream():
"""Sampling params are not mapped onto the A2A JSON-RPC payload, so the config
must not declare them as supported - declaring them used to drop them silently."""
assert A2AConfig().get_supported_openai_params(model="test-agent") == ["stream"]
def test_sampling_params_fail_loudly_instead_of_dropping_silently():
"""temperature/max_tokens/top_p are not forwarded to the agent; callers must get
a named error rather than a call that silently ignores their settings."""
from litellm.exceptions import UnsupportedParamsError
from litellm.utils import get_optional_params
for param in ("temperature", "max_tokens", "top_p"):
with pytest.raises(UnsupportedParamsError):
get_optional_params(model="test-agent", custom_llm_provider="a2a", **{param: 0.7})
def test_drop_params_still_drops_unsupported_sampling_params():
"""With drop_params set, unsupported sampling params are stripped and only the
supported stream flag survives."""
from litellm.utils import get_optional_params
result = get_optional_params(
model="test-agent",
custom_llm_provider="a2a",
temperature=0.7,
stream=True,
drop_params=True,
)
assert "temperature" not in result
assert result.get("stream") is True