fix(a2a): filter agent-only litellm_params from acompletion kwargs; pass agent_id into body

This commit is contained in:
Ishaan Jaffer 2026-04-23 15:18:22 -07:00
parent ffdf63df76
commit 0ad29239eb
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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(
{