From 69088bde006a2cc28ddb3f8e20e325da59f83a60 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Tue, 16 Jun 2026 11:18:30 +0200 Subject: [PATCH] fix(sdk): normalize chat_v0 output to the canonical Message shape chat_v0 returned the raw LiteLLM message, leaking provider-specific fields (provider_specific_fields, annotations) into outputs. Validate through the SDK Message model so the output is the canonical {role, content, name, tool_calls, tool_call_id}, matching what a hook/custom workflow returns. --- sdks/python/agenta/sdk/engines/running/handlers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdks/python/agenta/sdk/engines/running/handlers.py b/sdks/python/agenta/sdk/engines/running/handlers.py index fbc515674a..ac1174c9ad 100644 --- a/sdks/python/agenta/sdk/engines/running/handlers.py +++ b/sdks/python/agenta/sdk/engines/running/handlers.py @@ -2220,7 +2220,10 @@ async def chat_v0( message = response.choices[0].message # type: ignore - return message.model_dump(exclude_none=True) # type: ignore + # Normalize to the canonical Message shape (drops provider-specific fields). + return Message.model_validate(message.model_dump(exclude_none=True)).model_dump( + exclude_none=True + ) @instrument(ignore_inputs=["parameters"])