Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
A2AStreamingIterator
  • Loading branch information
ishaan-jaff committed Dec 11, 2025
commit e1a8da9dc880a82a7534e820b8201d13b956714d
12 changes: 10 additions & 2 deletions litellm/a2a_protocol/streaming_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import litellm
from litellm._logging import verbose_logger
from litellm.a2a_protocol.cost_calculator import A2ACostCalculator
from litellm.a2a_protocol.utils import A2ARequestUtils
from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
from litellm.litellm_core_utils.thread_pool_executor import executor
Expand Down Expand Up @@ -115,11 +116,17 @@ async def _handle_stream_complete(self) -> None:

# Set usage on logging obj
self.logging_obj.model_call_details["usage"] = usage
# Mark stream flag for downstream callbacks
self.logging_obj.model_call_details["stream"] = False

# Calculate cost using A2ACostCalculator
response_cost = A2ACostCalculator.calculate_a2a_cost(self.logging_obj)
self.logging_obj.model_call_details["response_cost"] = response_cost

# Build result for logging
result = self._build_logging_result(usage)

# Call success handlers
# Call success handlers - they will build standard_logging_object
asyncio.create_task(
self.logging_obj.async_success_handler(
result=result,
Expand All @@ -139,7 +146,8 @@ async def _handle_stream_complete(self) -> None:

verbose_logger.info(
f"A2A streaming completed: prompt_tokens={prompt_tokens}, "
f"completion_tokens={completion_tokens}, total_tokens={total_tokens}"
f"completion_tokens={completion_tokens}, total_tokens={total_tokens}, "
f"response_cost={response_cost}"
)

except Exception as e:
Expand Down