fix: always include content field on outgoing messages - #4
Open
hofftodd wants to merge 1 commit into
Open
Conversation
Assistant messages that carry only tool_calls are serialized by
agent_framework without a "content" key. OpenAI's official API
tolerates the omission, but stricter OpenAI-compatible backends
(vLLM-style gateways) reject the request with:
400 {'message': 'Field required', 'param': 'messages.N.content',
'code': 'missing'}
Since this scaffold targets local OpenAI-compatible servers by default
(openai_base_url: http://localhost:8080/v1), agents generated from it
are disproportionately likely to hit this on their first tool call.
Subclass OpenAIChatCompletionClient and override
_prepare_messages_for_openai (the documented customization hook) to
default "content" to "" on any message that lacks it. The key is only
added when absent, so text and multimodal messages are untouched, and
empty-string content alongside tool_calls is accepted by the official
API as well. This is a workaround for upstream agent_framework
serialization and can be dropped if fixed there.
Found while debugging an agent generated by this skill
(kyuz0/deep-research-agent); this upstreams the same fix.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Assistant messages that carry only
tool_callsare serialized byagent_frameworkwithout a"content"key. OpenAI's official API tolerates the omission, but stricter OpenAI-compatible backends (vLLM-style gateways and similar local servers) reject the request:Since this scaffold targets local OpenAI-compatible servers by default (
openai_base_url: http://localhost:8080/v1), agents generated from it are disproportionately likely to hit this on their very first tool call.Changes
Subclass
OpenAIChatCompletionClientand override_prepare_messages_for_openai(the documented customization hook) to default"content"to""on any message that lacks it. The key is only added when absent, so text and multimodal messages are untouched, and empty-string content alongsidetool_callsis accepted by the official API as well.This is a workaround for upstream
agent_frameworkserialization behavior and can be dropped if it's fixed there.Context
Found while debugging an agent generated by this skill — this is the scaffold-level version of kyuz0/deep-research-agent#2.
🤖 Generated with Claude Code