Skip to content

refactor(ios): unify generation paths via GenerationSink protocol#30

Merged
corasan merged 1 commit into
mainfrom
t3code/0921d753
Apr 24, 2026
Merged

refactor(ios): unify generation paths via GenerationSink protocol#30
corasan merged 1 commit into
mainfrom
t3code/0921d753

Conversation

@corasan
Copy link
Copy Markdown
Owner

@corasan corasan commented Apr 24, 2026

Summary

  • Introduce a GenerationSink protocol with StringGenerationSink and EventGenerationSink implementations, each owning the streaming concerns specific to its call site (token batching, thinking state machine, tool-call events, zero-width-space force-flush)
  • Collapse performGeneration and performGenerationWithEvents into a single engine that drives the generation loop, tool-execution task group, and history management through the sink
  • Public API (generate, stream, streamWithEvents) is unchanged; behavior preserved including firstTokenTime semantics, \u{200B} continuation marker (string-only), and thinking flush (event-only)

Test plan

  • Build iOS package (bun --cwd package build) with no compilation errors
  • Exercise generate (non-streaming) and confirm stats/output match prior behavior
  • Exercise stream with tool calls and verify the zero-width-space continuation marker still fires
  • Exercise streamWithEvents and verify thinking_start / thinking_chunk / thinking_end and tool_call_* events still emit correctly

Collapse performGeneration and performGenerationWithEvents into a single
engine parameterized by a GenerationSink. StringGenerationSink and
EventGenerationSink each own their streaming specifics (token batching,
thinking state machine, tool-call events, zero-width-space force-flush)
while sharing the generation loop, tool-execution task group, and history
management. Public API is unchanged.
@corasan corasan merged commit 493ff08 into main Apr 24, 2026
3 checks passed
@corasan corasan deleted the t3code/0921d753 branch April 24, 2026 15:06
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