[fix] Normalize chat workflow output to the canonical Message shape#4719
[fix] Normalize chat workflow output to the canonical Message shape#4719jp-agenta wants to merge 1 commit into
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughIn ChangesMessage Canonicalization in chat_v0
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Railway Preview Environment
|
Context
The
chat_v0workflow returned the raw LiteLLM message, leaking provider-specific fields intodata.outputs. So a basic chat call produced:{"content": "...", "role": "assistant", "provider_specific_fields": {"refusal": null}, "annotations": []}instead of the canonical message shape the rest of the platform uses.
Changes
chat_v0now validates its result through the SDKMessagemodel before dumping, sooutputsis the canonical{role, content, name, tool_calls, tool_call_id}(provider extras dropped). This matches what a custom/hook workflow returns after validating its own output throughMessage.Before:
{content, role, provider_specific_fields, annotations}After:
{role, content}(plus any of name/tool_calls/tool_call_id that are set)Tests / notes
Message.model_validatecleanly accepts a LiteLLM message dump with extras and yields the canonical fields.sdks/python/agenta/sdk/engines/running/handlers.py(chat_v0).🤖 Generated with Claude Code