From 0ad29239ebbbb4728c4c6aeee122f0c50a3e6d08 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 23 Apr 2026 15:18:22 -0700 Subject: [PATCH] fix(a2a): filter agent-only litellm_params from acompletion kwargs; pass agent_id into body --- .../a2a_protocol/litellm_completion_bridge/handler.py | 9 +++++++-- litellm/proxy/agent_endpoints/a2a_endpoints.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/litellm/a2a_protocol/litellm_completion_bridge/handler.py b/litellm/a2a_protocol/litellm_completion_bridge/handler.py index 53aac1d3e6a..4e66fe4ba67 100644 --- a/litellm/a2a_protocol/litellm_completion_bridge/handler.py +++ b/litellm/a2a_protocol/litellm_completion_bridge/handler.py @@ -20,6 +20,11 @@ from litellm.a2a_protocol.litellm_completion_bridge.transformation import ( ) from litellm.a2a_protocol.providers.config_manager import A2AProviderConfigManager +# Agent metadata fields stored in litellm_params that are not valid litellm.acompletion() kwargs +_AGENT_ONLY_PARAMS = frozenset( + {"is_public", "agent_name", "agent_id", "agent_card_params"} +) + class A2ACompletionBridgeHandler: """ @@ -99,7 +104,7 @@ class A2ACompletionBridgeHandler: litellm_params_to_add = { k: v for k, v in litellm_params.items() - if k not in ("model", "custom_llm_provider") + if k not in ("model", "custom_llm_provider") and k not in _AGENT_ONLY_PARAMS } completion_params.update(litellm_params_to_add) @@ -206,7 +211,7 @@ class A2ACompletionBridgeHandler: litellm_params_to_add = { k: v for k, v in litellm_params.items() - if k not in ("model", "custom_llm_provider") + if k not in ("model", "custom_llm_provider") and k not in _AGENT_ONLY_PARAMS } completion_params.update(litellm_params_to_add) diff --git a/litellm/proxy/agent_endpoints/a2a_endpoints.py b/litellm/proxy/agent_endpoints/a2a_endpoints.py index 9b18c766294..89119775c85 100644 --- a/litellm/proxy/agent_endpoints/a2a_endpoints.py +++ b/litellm/proxy/agent_endpoints/a2a_endpoints.py @@ -390,6 +390,7 @@ async def invoke_agent_a2a( # noqa: PLR0915 if "metadata" not in body: body["metadata"] = {} body["metadata"]["agent_id"] = agent.agent_id + body["agent_id"] = agent.agent_id body.update( {