Skip to content

A programming framework for agentic AI

fix: ensure serialized messages are passed to LLMStreamStartEvent (#6344)

Peter Jausovec4d3e47a0f13b
diff --git a/python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py b/python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py
index 3765c2ad2..8fcec588f 100644
--- a/python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py
+++ b/python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py
@@ -766,6 +766,7 @@ class BaseAnthropicChatCompletionClient(ChatCompletionClient):
stop_reason: Optional[str] = None
first_chunk = True
+ serialized_messages: List[Dict[str, Any]] = [self._serialize_message(msg) for msg in anthropic_messages]
# Process the stream
async for chunk in stream:
@@ -774,7 +775,7 @@ class BaseAnthropicChatCompletionClient(ChatCompletionClient):
# Emit the start event.
logger.info(
LLMStreamStartEvent(
- messages=cast(List[Dict[str, Any]], anthropic_messages),
+ messages=serialized_messages,
)
)
# Handle different event types