Skip to content

feat(provider): Responses API driver — streaming text (#540) - #548

Merged
smallnest merged 1 commit into
masterfrom
feat/issue-540-responses-streaming
Aug 2, 2026
Merged

feat(provider): Responses API driver — streaming text (#540)#548
smallnest merged 1 commit into
masterfrom
feat/issue-540-responses-streaming

Conversation

@smallnest

Copy link
Copy Markdown
Owner

Summary

  • Rewrite the resp_api driver pump from non-streaming Responses.New to Responses.NewStreaming, consuming the Responses SSE event union.
  • Text deltas emit cumulative StreamTextEvent partials (each carries the full accumulated text so the TUI renders a partial directly).
  • Terminal message is built from the authoritative response.completed envelope via the existing mapResponse, guaranteeing streaming/non-streaming parity by construction (US-004).
  • Fallback: a clean stream that never sent completed builds the terminal message from accumulated delta text with end_turn.
  • Dual failure model (FR-13): context cancellation, in-band error events, and transport/non-2xx failures ride the stream as a terminal StreamErrorEvent with StopReason=error; only a missing API key is an early returned error.
  • Driver tests converted to real text/event-stream stubs (sseResponse/deltaFrame/completedFrame).

Closes #540

Test plan

  • go build ./...
  • go vet ./internal/provider/
  • go test ./internal/provider/ (streaming incremental deltas, final aggregation == completed payload, context-cancel terminal error, in-band error event, upstream 401, missing-key early error)
  • Wire body asserts stream:true, instructions, model

Rewrite the resp_api driver's pump from a non-streaming Responses.New
call to Responses.NewStreaming, consuming the SSE event union: text
deltas emit cumulative StreamTextEvent partials, and the terminal
message is built from the authoritative response.completed envelope via
mapResponse so the final aggregation matches the non-streamed result by
construction. Context cancellation and in-band/transport errors ride the
stream as a terminal StreamErrorEvent (dual failure model). Driver tests
converted to real text/event-stream stubs.
@smallnest
smallnest merged commit 1c24f8c into master Aug 2, 2026
1 check passed
@smallnest
smallnest deleted the feat/issue-540-responses-streaming branch August 2, 2026 03:21
@smallnest smallnest mentioned this pull request Aug 2, 2026
5 tasks
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.

Responses 驱动 — 流式输出

1 participant