Skip to content

Streaming responses via Anthropic SSE #48

@owainlewis

Description

@owainlewis

`Provider.Complete` today returns once with the full response. SSE streaming would: render assistant text as it arrives, surface tool calls as soon as they're emitted (vs the whole turn completing first), and make long generations feel alive in the TUI.

Scope

  • Add `Provider.Stream(ctx, req) (<-chan StreamEvent, error)` (or extend `Complete` with a stream callback).
  • Bubble Tea: `textBlock` already exists; new partial-text update path that mutates the last block instead of appending.
  • Anthropic client: switch to `stream: true` and parse `event: …` / `data: …` SSE frames.
  • Cooperative cancel still works — closing the channel on ctx done aborts the stream cleanly.

Acceptance

  • Sonnet 4.6 generation visibly streams in the chat TUI.
  • Tool-use blocks still arrive correctly (Anthropic delimits them as content-block boundaries in streaming mode).
  • `neo flow` headless still works (line-printer can stream or buffer — pick buffer for cleanest CI logs).
  • Tests cover SSE parsing edge cases: split frames mid-buffer, comment lines, terminal `event: message_stop`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions