fix(coderd/x/chatd): handle truncated provider streams (#25074)

coder/fantasy now fails closed when Anthropic or OpenAI Responses
streams close before their provider terminal events instead of yielding
a successful finish.

This bumps the fantasy replacement to coder/fantasy#33 and teaches chat
error classification to treat those failures as retryable timeout errors
with explicit stream-closed messages.

<img width="875" height="311" alt="image"
src="https://github.com/user-attachments/assets/69c6f7b5-c885-46d2-a88b-b7a2b111bd55"
/>
This commit is contained in:
Ethan
2026-05-08 15:52:42 +10:00
committed by GitHub
parent de9cdca77e
commit b6dbc5614c
9 changed files with 215 additions and 15 deletions
+5 -3
View File
@@ -86,8 +86,10 @@ replace github.com/spf13/afero => github.com/aslilac/afero v0.0.0-20250403163713
// 7) coder/fantasy#mike/openai-responses-continuity, OpenAI Responses replay safety:
// replay stored reasoning item references, only replay web_search references
// when paired with reasoning, and validate function_call output pairing.
// See: https://github.com/coder/fantasy/commits/f83367a4a205
replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260427164812-d0e6ce2243af
// 8) coder/fantasy#33, fail closed when Anthropic or OpenAI Responses
// streams close before their terminal events.
// See: https://github.com/coder/fantasy/commits/246c4ae7aff9e
replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260507124503-246c4ae7aff9
// coder/coder uses a fork of charmbracelet's fork of the Anthropic Go SDK
// with performance improvements and Bedrock header cleanup.
@@ -500,6 +502,7 @@ require (
require (
charm.land/fantasy v0.8.1
github.com/anthropics/anthropic-sdk-go v1.19.0
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8
github.com/aymanbagabas/go-udiff v0.4.1
github.com/brianvoe/gofakeit/v7 v7.14.0
github.com/coder/agentapi-sdk-go v0.0.0-20250505131810-560d1d88d225
@@ -544,7 +547,6 @@ require (
github.com/aquasecurity/jfather v0.0.8 // indirect
github.com/aquasecurity/trivy v0.61.1-0.20250407075540-f1329c7ea1aa // indirect
github.com/aquasecurity/trivy-checks v1.12.2-0.20251219190323-79d27547baf5 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.13 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.21 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.97.3 // indirect