Skip to content

fix: handle empty string delta.content in OpenAI streaming - #48

Merged
kevincodex1 merged 1 commit into
Twigpine:mainfrom
auriti:fix/empty-string-content-delta
Apr 1, 2026
Merged

kevincodex1 merged 1 commit into
Twigpine:mainfrom
auriti:fix/empty-string-content-delta

Conversation

@auriti

@auriti auriti commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a protocol violation where some providers send "" as the first delta to signal streaming start
  • The falsy check if (delta.content) treated empty string as absent, skipping content_block_start — the next delta with actual text was emitted without it, breaking the Anthropic event sequence

Changes

1 line changed in src/services/api/openaiShim.ts — if (delta.content) → if (delta.content != null).

Relates to

#42

Some providers send an empty string as the first delta to signal
streaming start. The falsy check `if (delta.content)` treated "" as
absent, skipping content_block_start. The next delta with actual
content was emitted without it, violating the Anthropic protocol.

Changed to `delta.content != null` to distinguish between absent field
and empty string.

Relates to Twigpine#42

Co-Authored-By: Juan Camilo <juancamilo.auriti@gmail.com>
@kevincodex1
kevincodex1 merged commit 80df0c5 into Twigpine:main Apr 1, 2026
euxaristia pushed a commit to euxaristia/openclaude that referenced this pull request Apr 13, 2026
…elta

fix: handle empty string delta.content in OpenAI streaming
reymaster pushed a commit to reymaster/openclaude that referenced this pull request May 5, 2026
…elta

fix: handle empty string delta.content in OpenAI streaming
thedeveloloper pushed a commit to thedeveloloper/openclaude that referenced this pull request Jun 8, 2026
…elta

fix: handle empty string delta.content in OpenAI streaming
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.

2 participants