Skip to content

Assistant messages missing 'content' field when sending tool calls to certain OpenAI-compatible providers #6717

@kyler505

Description

@kyler505

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:

  1. Configure a custom OpenAI provider in ~/.config/goose/config.yaml using a base URL that points to a strict OpenAI-compatible API (e.g., TAMU API).
  2. Start a goose session: goose session.
  3. Ask a question that requires a tool call, such as "What time is it?".
  4. See error: The provider returns a 400 Bad Request because the assistant message lacks a content field.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedGreat issue for non-Block contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions