litellm/tests/test_litellm/a2a_protocol
Yassin Kortam 996693f1eb
fix(a2a): accept the whole JSON-RPC id union the spec defines (#37704)
JSON-RPC 2.0 types `id` as string, integer or null, but
LiteLLMSendMessageResponse annotated it as a bare required `str`. Pydantic v2
dropped v1's int-to-str coercion, so an upstream agent echoing an integer id was
rejected outright, and a null id, which section 5 requires for an error that
cannot be correlated to a request, was rejected too. Both surfaced as -32603 with
a pydantic ValidationError in the message: five distinct 500s on
/a2a/{agent_id}, across message/send and tasks/get.

Everything around the model already handled the full union: the endpoint reads
the id off the body as Any, its helpers are typed `str | int | None`, the error
builder takes `object`, and the streaming path passes the id through untouched.
The response model was the only narrowing left.

Backfilling an id the agent omitted keeps the caller's type too, since JSON-RPC
requires the response id to equal the request id and a caller that sent 7 cannot
correlate a response carrying "7".

`bool` is excluded from the integer half even though it subclasses `int`, so a
boolean id is stringified rather than relayed as 1 or 0, where it would collide
with a real integer id another in-flight request may be using.
2026-08-20 14:41:22 -07:00
..
providers test: run the 30 test files stranded in the second mirror (#37595) 2026-08-20 10:59:43 -07:00
__init__.py fix(a2a): record agent cost_per_query and input tokens on native send path (#31979) 2026-07-03 09:25:42 +05:30
test_a2a_exception_mapping_utils.py fix(a2a): stop writing per-caller state onto the shared cached httpx client (#35978) 2026-08-06 18:58:26 -07:00
test_a2a_streaming_iterator.py fix(responses): stop scheduling sync success_handler concurrently with async_success_handler (#32239) 2026-07-07 09:13:50 -07:00
test_card_resolver.py feat(a2a): support a2a-sdk 1.x proxy routing for 0.3 and 1.0 agents (#30950) 2026-06-29 09:32:39 +05:30
test_completion_bridge_streaming.py feat(a2a): well-known agent-card discovery + LangGraph Platform mode (#28860) 2026-05-29 20:50:42 -07:00
test_cost_calculator.py fix(a2a): record agent cost_per_query and input tokens on native send path (#31979) 2026-07-03 09:25:42 +05:30
test_main.py fix(http): stop pooled clients persisting cookies on the aiohttp jar too (#36149) 2026-08-07 11:05:59 -07:00
test_send_message_response.py fix(a2a): accept the whole JSON-RPC id union the spec defines (#37704) 2026-08-20 14:41:22 -07:00
test_utils.py fix(a2a): record agent cost_per_query and input tokens on native send path (#31979) 2026-07-03 09:25:42 +05:30