Skip to content

fix: resolve SSE streaming header duplication and event ID continuity#8

Merged
liut merged 1 commit intomainfrom
fix/sse-header-and-chunk-index
Mar 11, 2026
Merged

fix: resolve SSE streaming header duplication and event ID continuity#8
liut merged 1 commit intomainfrom
fix/sse-header-and-chunk-index

Conversation

@liut
Copy link
Owner

@liut liut commented Mar 11, 2026

Summary

  • Fix HTTP headers being set repeatedly in tool call loop - now set only once before streaming
  • Fix SSE event ID not continuing across tool call iterations - add chunkIdx field to maintain global incrementing IDs
  • Fix ConversationID assignment in non-SSE mode (cm.IDccr.cs.GetID())
  • Fix tool_calls detection using strong type FinishReasonToolCalls
  • Add llm.FinishReason type definition and constants

Changes

  • pkg/web/api/handle_convo.go: Move HTTP header setup to chatStreamResponseLoop, use ccr.chunkIdx for SSE event IDs
  • pkg/services/llm/types.go: Add FinishReason type and constants
  • pkg/services/llm/openai.go: Use FinishReason type for stream response
  • pkg/settings/config.go: Make Provider.URL required

- Move HTTP header setup outside the loop in chatStreamResponseLoop to set only once
- Add chunkIdx field to maintain global incrementing event IDs across tool call loops
- Fix ConversationID assignment in non-SSE mode (cm.ID -> ccr.cs.GetID())
- Fix tool_calls detection logic using FinishReasonToolCalls strong type
- Add llm.FinishReason type definition and constants

Other:
- Make Provider.URL a required config
@liut liut merged commit 06d5196 into main Mar 11, 2026
2 checks passed
liut added a commit that referenced this pull request Mar 13, 2026
- Add Tools map to Preset struct for custom tool descriptions
- Add ApplyToolDescriptions method to Registry
- Update README with new preset configuration examples

Closes: #8
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