Skip to content

Add EventThinking for reasoning tokens - #54

Merged
x2d7 merged 3 commits into
mainfrom
feature/thinking-events
Jun 1, 2026
Merged

Add EventThinking for reasoning tokens#54
x2d7 merged 3 commits into
mainfrom
feature/thinking-events

Conversation

@x2d7

@x2d7 x2d7 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

Add new EventThinking event type for reasoning/thinking tokens streamed by models with extended thinking support (e.g. Qwen3).

Changes

  • chat/events.go: Added EventThinking struct and eventThinking constant
  • chat/serial.go: Added eventThinking case to UnmarshalEvent
  • chat/chat.go: Added thinkingBuilder to sessionState; thinking tokens accumulate separately, reasoning message emitted at end of completion round (Variant A)
  • connect/openai/stream.go: Extract reasoning_content from delta.JSON.ExtraFields (SDK lacks dedicated field)
  • go.mod: Updated openai-go SDK from v3.17.0 to v3.37.0

Tests

  • EventThinking round-trip serialization test
  • OpenAI parser tests: reasoning-only, reasoning+content chunks
  • Session-level test: thinking tokens accumulated into assistant message
  • Coverage: 89% (≥75% threshold met)

Behavior

  • Thinking tokens passed through streaming channel as EventThinking
  • At completion end, accumulated thinking content emitted as EventAssistantMessage
  • Regular content tokens unchanged

x2d7 added 3 commits June 1, 2026 05:15
- Add EventThinking event type for reasoning/thinking tokens
- Extract reasoning_content from OpenAI delta ExtraFields
- Accumulate thinking tokens in separate builder per session round
- Emit reasoning as assistant message at end of completion round
- Update openai-go SDK from v3.17.0 to v3.37.0
- Add tests for EventThinking serialization and OpenAI parsing
@x2d7 x2d7 changed the title feat: add EventThinking for reasoning tokens Add EventThinking for reasoning tokens Jun 1, 2026
@x2d7
x2d7 merged commit 776c328 into main Jun 1, 2026
1 check passed
@x2d7
x2d7 deleted the feature/thinking-events branch June 1, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant