Skip to content

fix: improve streaming reliability and max_completion_tokens support#220

Open
alext-avi wants to merge 1 commit intoericc-ch:masterfrom
alext-avi:fix/streaming-reliability
Open

fix: improve streaming reliability and max_completion_tokens support#220
alext-avi wants to merge 1 commit intoericc-ch:masterfrom
alext-avi:fix/streaming-reliability

Conversation

@alext-avi
Copy link
Copy Markdown

Summary

  • Return raw Response from createChatCompletions instead of parsing SSE in the service layer, allowing the OpenAI-compatible handler to pipe streams directly via TransformStream (avoids re-serialization overhead and buffering issues)
  • Anthropic /messages handler now parses SSE at the handler level where event translation is needed
  • Normalize max_completion_tokens to max_tokens for upstream compatibility (some clients send the newer OpenAI field which Copilot doesn't accept)
  • Set Bun idleTimeout: 0 to prevent premature SSE connection kills (default 10s was dropping long-running LLM streams)

Test plan

  • Verified streaming responses work end-to-end with Claude Code via OpenAI-compatible endpoint
  • Verified Anthropic /messages streaming translation still works
  • Verified non-streaming responses are unaffected
  • Confirmed long-running streams no longer get killed by Bun's idle timeout

🤖 Generated with Claude Code

- Return raw Response from createChatCompletions instead of parsing SSE
  in the service layer, allowing handlers to pipe streams directly
- Pipe OpenAI-compatible streams through a monitoring TransformStream
  for TTFT and throughput logging without re-serializing
- Anthropic /messages handler now parses SSE at the handler level where
  it needs to translate events
- Normalize max_completion_tokens to max_tokens for upstream compat
- Set Bun idleTimeout to 0 to prevent premature SSE connection kills
  (default 10s was dropping long-running LLM streams)

Co-Authored-By: Claude Opus 4.6 (1M context) <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