-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Assistant messages missing 'content' field when sending tool calls to certain OpenAI-compatible providers #6717
Description
GitHub Issue: Assistant messages missing 'content' field when sending tool calls
Title: Assistant messages missing 'content' field when sending tool calls to certain OpenAI-compatible providers
Describe the bug
💡 Before filing, please check common issues:
https://block.github.io/goose/docs/troubleshooting
📦 To help us debug faster, attach your diagnostics zip if possible.
👉 How to capture it: https://block.github.io/goose/docs/troubleshooting/diagnostics-and-reporting/
When Goose sends an assistant message containing tool calls (via the OpenAI provider engine), it omits the content field entirely if there is no accompanying text content. While this is valid in some OpenAI contexts, many strict OpenAI-compatible providers (such as the TAMU AI API or certain custom proxies) require the content field to be present (e.g., as an empty string "" or null) whenever tool_calls are provided. This results in a 400 Bad Request from the provider.
The issue is located in crates/goose/src/providers/formats/openai.rs. The format_messages function only adds the content key if content_array or text_array is non-empty.
To Reproduce
Steps to reproduce the behavior:
- Configure a custom OpenAI provider in
~/.config/goose/config.yamlusing a base URL that points to a strict OpenAI-compatible API (e.g., TAMU API). - Start a goose session:
goose session. - Ask a question that requires a tool call, such as "What time is it?".
- See error: The provider returns a
400 Bad Requestbecause the assistant message lacks acontentfield.
Expected behavior
Goose should include "content": "" or "content": null in the assistant message when tool calls are present but text content is not.
Screenshots
N/A
Please provide the following information
- OS & Arch: macOS arm64
- Interface: CLI
- Version: v1.21.1
- Extensions enabled: Developer (default)
- Provider & Model: custom_tamu_ai (OpenAI engine) / protected.gpt-5.2
Additional context
Workaround involves using a proxy script to inject the missing field:
if msg.get("role") == "assistant" and "content" not in msg:
msg["content"] = ""This confirms that adding the field resolves the issue.