refactor(a2a): drop dead openai_chunk_to_a2a_chunk helper

The deprecated single-chunk helper has no callers anywhere in the
codebase — the streaming path emits proper A2A events via
create_task_event / create_status_update_event /
create_artifact_update_event in handler.py. Removing the dead method
also eliminates the inconsistency where the unused chunk inlined the
envelope-level final flag inside the Message result.
This commit is contained in:
mateo-berri 2026-05-28 03:59:26 +00:00
parent c5cf17ab39
commit 2cb4a8c254
No known key found for this signature in database

View file

@ -304,55 +304,3 @@ class A2ACompletionBridgeTransformation:
},
}
@staticmethod
def openai_chunk_to_a2a_chunk(
chunk: Any,
request_id: Optional[str] = None,
is_final: bool = False,
) -> Optional[Dict[str, Any]]:
"""
Transform a LiteLLM streaming chunk to A2A streaming format.
NOTE: This method is deprecated for streaming. Use the event-based
methods (create_task_event, create_status_update_event,
create_artifact_update_event) instead for proper A2A streaming.
Args:
chunk: LiteLLM ModelResponse chunk
request_id: Original A2A request ID
is_final: Whether this is the final chunk
Returns:
A2A streaming chunk dict or None if no content
"""
# Extract delta content
content = ""
if chunk is not None and hasattr(chunk, "choices") and chunk.choices:
choice = chunk.choices[0]
if hasattr(choice, "delta") and choice.delta:
content = choice.delta.content or ""
if not content and not is_final:
return None
# Build A2A streaming chunk. Mirrors the non-streaming response
# shape (``result`` is the message itself, with ``kind: "message"``
# as the result-level event discriminator — matching how
# ``create_artifact_update_event`` uses ``kind: "artifact-update"``
# at the result level). ``final`` is an envelope-level streaming
# property per the A2A spec and is appended alongside the message
# fields so consumers can read a uniform ``result`` shape across
# streaming and non-streaming.
a2a_chunk = {
"jsonrpc": "2.0",
"id": request_id,
"result": {
"kind": "message",
"role": "agent",
"parts": [{"kind": "text", "text": content}],
"messageId": uuid4().hex,
"final": is_final,
},
}
return a2a_chunk