Skip to content

refactor(model): centralize early stream termination classification#184

Merged
raphael merged 1 commit into
mainfrom
refactor/stream-ended-early
Jul 15, 2026
Merged

refactor(model): centralize early stream termination classification#184
raphael merged 1 commit into
mainfrom
refactor/stream-ended-early

Conversation

@raphael

@raphael raphael commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds model.NewStreamEndedEarlyError(provider, operation, started) as the single classifier for streams that close cleanly before message stop: never-started streams yield the retryable empty-stream error (errors.Is(err, model.ErrEmptyStream)), mid-message closes yield the retryable truncated_stream provider error without the sentinel.
  • Deletes the duplicated streamEndedEarlyError helpers from the Bedrock and Anthropic adapters; both now call the model constructor. Error kinds, codes, and messages are unchanged.
  • Moves the classification test into the model package and documents the constructor in DESIGN.md.

Test plan

  • go test ./...
  • make lint

Move the empty-vs-truncated classification of streams that close before
message stop into model.NewStreamEndedEarlyError, deleting the duplicated
streamEndedEarlyError helpers in the Bedrock and Anthropic adapters. The
model package owns the stream integrity error contract; adapters now only
report the provider, operation, and whether a message had started.
@raphael
raphael merged commit 9a18e19 into main Jul 15, 2026
2 checks passed
@raphael
raphael deleted the refactor/stream-ended-early branch July 15, 2026 05:41
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