Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
79ffe24
feat(a2a): well-known agent-card discovery + LangGraph Platform mode
Sameerlite May 26, 2026
20129d4
fix(a2a): preserve agent url, fix streaming chunk envelope, and prote…
cursoragent May 26, 2026
afc8b10
fix(a2a): fix legacy streaming chunk, agent card test, and metadata m…
cursoragent May 26, 2026
78591b2
fix(a2a): remove dead duplicate transformation dir; drop SSRF-prone h…
cursoragent May 26, 2026
1728e9f
fix(a2a): revert accidental html→index.html rename from afc8b10f
Sameerlite May 27, 2026
78cc67c
fix(a2a): address PR review comments
Sameerlite May 27, 2026
7eb3f4d
fix: restore Next.js metadata directories to match upstream main
Sameerlite May 27, 2026
ac6bc79
fix(a2a): drop dead headers option from discoverAgentCardCall
mateo-berri May 28, 2026
42b4449
fix(a2a): skip merge for non-A2A agents and align pydantic-ai result …
mateo-berri May 28, 2026
a65357f
Fix three bugs in A2A discovery flow
cursoragent May 28, 2026
a3f958d
fix(a2a/ui): include savedAgentCard in handleDiscover deps
cursoragent May 28, 2026
a0944e1
fix(a2a): align pydantic-ai test + docstring with direct-Message resu…
mateo-berri May 28, 2026
06384db
fix(a2a): strip additionalInterfaces and let configured metadata win …
mateo-berri May 28, 2026
c5cf17a
fix(agents): merge agent card even when agent_card_params is an empty…
cursoragent May 28, 2026
2cb4a8c
refactor(a2a): drop dead openai_chunk_to_a2a_chunk helper
mateo-berri May 28, 2026
a294fbe
fix(a2a): scope a2a lazy-feature so it doesn't subsume /v1/a2a/discover
mateo-berri May 28, 2026
c1eb1eb
style: black-format litellm/a2a_protocol/litellm_completion_bridge/tr…
mateo-berri May 28, 2026
59e36bc
fix: address PR bugfix review for a2a discovery + metadata forwarding
cursoragent May 28, 2026
da4d9ce
fix(a2a): return 404 from get_agent_card when agent has no card
mateo-berri May 28, 2026
4e3cdda
fix(agents): apply discovery overlay uniformly on create and dedupe A…
cursoragent May 28, 2026
824a786
ci(proxy-endpoints): wire tests/test_litellm/proxy/a2a into the shard
mateo-berri May 28, 2026
84e778e
fix(ui): overlay discovered name/description in create flow for dynam…
cursoragent May 28, 2026
8145ece
fix(a2a): default merged agent card version, null-guard runtime URL l…
mateo-berri May 28, 2026
1a9bce3
fix(ui): extract overlayDiscoveredCardParams + debounce parent-driven…
mateo-berri May 28, 2026
65484a8
fix(a2a): preserve discovery name edit, default discovery headers, sy…
cursoragent May 28, 2026
70fe8e5
fix(a2a): scrub upstream url from /public/agent_hub cards
mateo-berri May 28, 2026
27c5098
fix(a2a): include suffix-matched routes in lazy warm openapi fragment
mateo-berri May 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions litellm/a2a_protocol/litellm_completion_bridge/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ async def handle_non_streaming(
"api_base": api_base,
"stream": False,
}
A2ACompletionBridgeTransformation.apply_forward_metadata_to_completion_params(
completion_params=completion_params,
a2a_message=message,
params=params,
)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
# Add litellm_params (contains api_key, client_id, client_secret, tenant_id, etc.)
litellm_params_to_add = {
k: v
Expand Down Expand Up @@ -207,6 +212,11 @@ async def handle_streaming(
"api_base": api_base,
"stream": True,
}
A2ACompletionBridgeTransformation.apply_forward_metadata_to_completion_params(
completion_params=completion_params,
a2a_message=message,
params=params,
)
# Add litellm_params (contains api_key, client_id, client_secret, tenant_id, etc.)
litellm_params_to_add = {
k: v
Expand Down
95 changes: 77 additions & 18 deletions litellm/a2a_protocol/litellm_completion_bridge/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,72 @@ class A2ACompletionBridgeTransformation:
Static methods for transforming between A2A and OpenAI message formats.
"""

@staticmethod
def _extract_text_from_a2a_parts(parts: List[Dict[str, Any]]) -> str:
"""Extract text from A2A parts (with or without explicit ``kind``)."""
content_parts: List[str] = []
for part in parts:
if not isinstance(part, dict):
continue
kind = part.get("kind")
text = part.get("text")
if text is None:
continue
if kind in (None, "", "text"):
content_parts.append(str(text))
return "\n".join(content_parts)

@staticmethod
def get_forward_metadata(
a2a_message: Dict[str, Any],
params: Optional[Dict[str, Any]] = None,
) -> Optional[Dict[str, Any]]:
"""
Merge A2A metadata from MessageSendParams and the message for downstream providers.

Forwarded once on the LangGraph run payload (``metadata``), not duplicated on
each input message — see ``apply_forward_metadata_to_completion_params``.
"""
merged: Dict[str, Any] = {}
if params and isinstance(params.get("metadata"), dict):
merged.update(params["metadata"])
message_metadata = a2a_message.get("metadata")
if isinstance(message_metadata, dict):
merged.update(message_metadata)
return merged or None
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

@staticmethod
def apply_forward_metadata_to_completion_params(
completion_params: Dict[str, Any],
a2a_message: Dict[str, Any],
params: Optional[Dict[str, Any]] = None,
) -> None:
"""
Attach A2A metadata to completion kwargs for provider bridges (e.g. LangGraph).

Uses ``extra_body`` so we do not collide with LiteLLM's spend-log ``metadata`` kwarg.
"""
forward_metadata = A2ACompletionBridgeTransformation.get_forward_metadata(
a2a_message=a2a_message,
params=params,
)
if not forward_metadata:
return

extra_body = completion_params.get("extra_body")
if not isinstance(extra_body, dict):
extra_body = {}
extra_body = {**extra_body, "metadata": forward_metadata}
completion_params["extra_body"] = extra_body
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Comment thread
Sameerlite marked this conversation as resolved.
Resolved

verbose_logger.debug(
f"A2A -> completion forward metadata keys={list(forward_metadata.keys())}"
)

@staticmethod
def a2a_message_to_openai_messages(
a2a_message: Dict[str, Any],
) -> List[Dict[str, str]]:
) -> List[Dict[str, Any]]:
"""
Transform an A2A message to OpenAI message format.

Expand All @@ -70,21 +132,20 @@ def a2a_message_to_openai_messages(
elif role == "system":
openai_role = "system"

# Extract text content from parts
content_parts = []
for part in parts:
kind = part.get("kind", "")
if kind == "text":
text = part.get("text", "")
content_parts.append(text)
if not isinstance(parts, list):
parts = []

content = A2ACompletionBridgeTransformation._extract_text_from_a2a_parts(parts)

content = "\n".join(content_parts) if content_parts else ""
# Do not attach A2A message.metadata here — the completion bridge forwards it
# once at run level via extra_body.metadata (LangGraph POST /runs/wait shape).
openai_message: Dict[str, Any] = {"role": openai_role, "content": content}

verbose_logger.debug(
f"A2A -> OpenAI transform: role={role} -> {openai_role}, content_length={len(content)}"
)

return [{"role": openai_role, "content": content}]
return [openai_message]

@staticmethod
def openai_response_to_a2a_response(
Expand All @@ -110,6 +171,7 @@ def openai_response_to_a2a_response(

# Build A2A message
a2a_message = {
"kind": "message",
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
Expand All @@ -119,9 +181,7 @@ def openai_response_to_a2a_response(
a2a_response = {
"jsonrpc": "2.0",
"id": request_id,
"result": {
"message": a2a_message,
},
"result": a2a_message,
}

Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
verbose_logger.debug(f"OpenAI -> A2A transform: content_length={len(content)}")
Expand Down Expand Up @@ -272,11 +332,10 @@ def openai_chunk_to_a2a_chunk(
"jsonrpc": "2.0",
"id": request_id,
"result": {
"message": {
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
},
"kind": "message",
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
"final": is_final,
},
}
Expand Down
10 changes: 10 additions & 0 deletions litellm/a2a_protocol/providers/litellm_completion/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ async def handle_non_streaming(
"api_base": api_base,
"stream": False,
}
A2ACompletionBridgeTransformation.apply_forward_metadata_to_completion_params(
completion_params=completion_params,
a2a_message=message,
params=params,
)
# Add litellm_params (contains api_key, client_id, client_secret, tenant_id, etc.)
litellm_params_to_add = {
k: v
Expand Down Expand Up @@ -206,6 +211,11 @@ async def handle_streaming(
"api_base": api_base,
"stream": True,
}
A2ACompletionBridgeTransformation.apply_forward_metadata_to_completion_params(
completion_params=completion_params,
a2a_message=message,
params=params,
)
# Add litellm_params (contains api_key, client_id, client_secret, tenant_id, etc.)
litellm_params_to_add = {
k: v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def openai_response_to_a2a_response(

# Build A2A message
a2a_message = {
"kind": "message",
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
Expand All @@ -119,9 +120,7 @@ def openai_response_to_a2a_response(
a2a_response = {
"jsonrpc": "2.0",
"id": request_id,
"result": {
"message": a2a_message,
},
"result": a2a_message,
}

verbose_logger.debug(f"OpenAI -> A2A transform: content_length={len(content)}")
Expand Down Expand Up @@ -272,11 +271,10 @@ def openai_chunk_to_a2a_chunk(
"jsonrpc": "2.0",
"id": request_id,
"result": {
"message": {
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
},
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
"kind": "message",
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
"final": is_final,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ def _transform_to_a2a_response(
"jsonrpc": "2.0",
"id": request_id,
"result": {
"message": a2a_message,
"kind": "message",
**a2a_message,
},
}

Expand Down
4 changes: 4 additions & 0 deletions litellm/a2a_protocol/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def extract_text_from_response(response_dict: Dict[str, Any]) -> str:
if not isinstance(result, dict):
return ""

# Direct message format (A2A spec)
if result.get("kind") == "message" or "parts" in result:
return A2ARequestUtils.extract_text_from_message(result)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

message = result.get("message", {})
return A2ARequestUtils.extract_text_from_message(message)

Expand Down
16 changes: 13 additions & 3 deletions litellm/llms/langgraph/chat/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,16 @@ def _get_assistant_id(self, model: str, optional_params: dict) -> str:

def _convert_messages_to_langgraph_format(
self, messages: List[AllMessageValues]
) -> List[Dict[str, str]]:
) -> List[Dict[str, Any]]:
"""
Convert OpenAI-format messages to LangGraph format.

OpenAI format: {"role": "user", "content": "..."}
LangGraph format: {"role": "human", "content": "..."}

Preserves per-message ``metadata`` when present (e.g. A2A ``skillId``).
"""
langgraph_messages: List[Dict[str, str]] = []
langgraph_messages: List[Dict[str, Any]] = []
for msg in messages:
role = msg.get("role", "user")
content = msg.get("content", "")
Expand All @@ -169,7 +171,15 @@ def _convert_messages_to_langgraph_format(
if not isinstance(content, str):
content = str(content)

langgraph_messages.append({"role": langgraph_role, "content": content})
langgraph_message: Dict[str, Any] = {
"role": langgraph_role,
"content": content,
}
message_metadata = msg.get("metadata")
if isinstance(message_metadata, dict) and message_metadata:
langgraph_message["metadata"] = message_metadata

langgraph_messages.append(langgraph_message)

return langgraph_messages

Expand Down
5 changes: 5 additions & 0 deletions litellm/proxy/_lazy_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class LazyFeature:
module_path="litellm.proxy.agent_endpoints.a2a_endpoints",
path_prefixes=("/a2a", "/v1/a2a"),
),
LazyFeature(
name="a2a_registration",
module_path="litellm.proxy.a2a.endpoints",
path_prefixes=("/v1/a2a/discover",),
),
Comment thread
Sameerlite marked this conversation as resolved.
Resolved
LazyFeature(
name="vector_stores",
module_path="litellm.proxy.vector_store_endpoints.endpoints",
Expand Down
29 changes: 29 additions & 0 deletions litellm/proxy/a2a/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
A2A registration helpers for the LiteLLM proxy.

- ``discovery``: fetches the upstream agent's well-known card so the UI can
display its skills/capabilities for the user to pick from.
- ``agent_card``: pure merge logic that builds the LiteLLM-fronted agent card
from the upstream card + the values the user set in the UI.
- ``endpoints``: FastAPI routes that wire the above into the proxy.
"""

from litellm.proxy.a2a.agent_card import (
LITELLM_A2A_PROTOCOL_VERSION,
LITELLM_SECURITY_SCHEMES,
LITELLM_SECURITY_REQUIREMENTS,
merge_agent_card,
)
from litellm.proxy.a2a.discovery import (
AGENT_CARD_WELL_KNOWN_PATHS,
fetch_well_known_card,
)

__all__ = [
"AGENT_CARD_WELL_KNOWN_PATHS",
"LITELLM_A2A_PROTOCOL_VERSION",
"LITELLM_SECURITY_REQUIREMENTS",
"LITELLM_SECURITY_SCHEMES",
"fetch_well_known_card",
"merge_agent_card",
]
Loading
Loading