Skip to content

Conversation

@charignon
Copy link

Problem

OpenAI models can halt or produce unexpected behavior when they receive empty tool results. This commonly happens when using the Claude CLI with:

  • File reads that return empty files
  • Shell commands with no output
  • API calls that return empty responses

The Claude CLI sends these empty results normally (Anthropic handles them fine), but OpenAI models often just stop generating without any error. This is particularly frustrating when using the proxy with agentic workflows.

Solution

Add an opt-in fix via environment variables:

  • FIX_EMPTY_TOOL_RESULTS=1 - Enable the fix
  • EMPTY_TOOL_RESULT_PLACEHOLDER - Custom placeholder (default: "NULL")

When enabled, empty tool result content is replaced with the placeholder string, which OpenAI models handle correctly.

Usage

FIX_EMPTY_TOOL_RESULTS=1 python server.py

Changes

  • Add fix_empty_tool_result() helper function
  • Apply fix in parse_tool_result_content() at all return points
  • Add environment variable configuration
  • No breaking changes (disabled by default)

Co-authored with Claude Code

OpenAI models can halt when receiving empty tool results (from empty files,
commands with no output, etc.). This adds an opt-in fix via FIX_EMPTY_TOOL_RESULTS=1
that replaces empty content with a placeholder string.

Co-authored with Claude Code (https://claude.ai/claude-code)
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