Skip to content

fix: always include content field on outgoing messages - #4

Open
hofftodd wants to merge 1 commit into
kyuz0:mainfrom
hofftodd:fix/tool-call-content-field
Open

fix: always include content field on outgoing messages#4
hofftodd wants to merge 1 commit into
kyuz0:mainfrom
hofftodd:fix/tool-call-content-field

Conversation

@hofftodd

@hofftodd hofftodd commented Jul 9, 2026

Copy link
Copy Markdown

Summary

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 and similar local servers) reject the request:

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 very first tool call.

Changes

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 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant