Skip to content

fix: add stream_data_buffer_size config to handle large SSE responses#15

Merged
x5iu merged 2 commits into
mainfrom
fix/stream-data-buffer-size
Dec 26, 2025
Merged

fix: add stream_data_buffer_size config to handle large SSE responses#15
x5iu merged 2 commits into
mainfrom
fix/stream-data-buffer-size

Conversation

@x5iu
Copy link
Copy Markdown
Owner

@x5iu x5iu commented Dec 26, 2025

Summary

  • Add stream_data_buffer_size configuration option to control the maximum size of a single line in SSE streams
  • Default value is 1MB (compared to bufio.Scanner's default 64KB), which should be sufficient for most model responses
  • Fix potential "token too long" errors when models return very long content

Changes

  • Add StreamDataBufferSize field to OptionsConfig struct
  • Add GetStreamDataBufferSize() method with 1MB default
  • Update MakeAnthropicStream and makeOpenRouterStream to use configurable buffer
  • Remove unused RootConfig and ProfileConfig structs (cleanup)

Configuration Example

profiles:
  default:
    options:
      stream_data_buffer_size: 2097152  # 2MB

Test plan

  • go vet ./... passes
  • Unit tests pass
  • Manual testing with large model responses

🤖 Generated with Claude Code

bufio.Scanner has a default max token size of 64KB which can cause
"token too long" errors when models return very long content in a
single SSE event.

This change adds a configurable stream_data_buffer_size option
(default 1MB) to allow handling larger SSE responses.

Changes:
- Add StreamDataBufferSize field to OptionsConfig
- Add GetStreamDataBufferSize() method with 1MB default
- Update MakeAnthropicStream to use configurable buffer
- Update makeOpenRouterStream to use configurable buffer
- Remove unused RootConfig and ProfileConfig structs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@x5iu x5iu force-pushed the fix/stream-data-buffer-size branch from 65771d2 to 5c41b7d Compare December 26, 2025 10:21
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@x5iu x5iu merged commit 70a5915 into main Dec 26, 2025
1 check passed
@x5iu x5iu deleted the fix/stream-data-buffer-size branch December 26, 2025 10:49
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