fix: include content field on assistant tool_calls messages - #134
Open
truffle-dev wants to merge 1 commit into
Open
fix: include content field on assistant tool_calls messages#134truffle-dev wants to merge 1 commit into
truffle-dev wants to merge 1 commit into
Conversation
The ToolUse arm of chat_message_to_openai_message returned None for content. Because OpenAIChatMessage.content is skip_serializing_if = Option::is_none, that dropped the field from the serialized request. Strict OpenAI-compatible APIs such as OpenRouter reject an assistant message that carries tool_calls without a content field, breaking any multi-turn tool loop through those providers. Emit the message content string instead, matching the OpenAI schema. Fixes graniet#111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assistant messages built from
MessageType::ToolUseserialize theirtool_callsarray but drop thecontentfield entirely. Inchat_message_to_openai_messagethe tool-use arm returnscontent: None, and becauseOpenAIChatMessage.contentis annotatedskip_serializing_if = "Option::is_none", the field never reaches the wire.Strict OpenAI-compatible providers such as OpenRouter reject an assistant message that carries
tool_callswithout acontentfield, so any multi-turn tool loop routed through them fails after the first tool call. The OpenAI schema allowscontentto be an empty string alongsidetool_calls, which is what this emits.Serialized assistant tool-call message before / after:
Added a regression test asserting the serialized message keeps both
contentandtool_calls. Verified it fails on the oldNonearm and passes with the fix.Fixes #111