on main help sign in
fix: hyper provider cancel (#2133)
commit8adfe70c4454363bc839ca405657de91da01998b authorKujtim Hoxha <kujtimii.h@gmail.com> dateThu 5 Feb 2026, 14:06 (8 months ago) parent9013bb0
1 file changed+10−4
internal/agent/hyper/provider.go+10−4
internal/agent/hyper/provider.go+10−4
@@ -252,10 +252,16 @@ func (m *languageModel) Stream(ctx context.Context, call fantasy.Call) (fantasy.
252252 continue
253253 }
254254 }
255− if err := scanner.Err(); err != nil &&
256− !errors.Is(err, context.Canceled) &&
257− !errors.Is(err, context.DeadlineExceeded) {
258− yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeError, Error: err})
255+ if err := scanner.Err(); err != nil {
256+ if sawFinish && (errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)) {
257+ // If we already saw an explicit finish event, treat cancellation as a no-op.
258+ } else {
259+ _ = yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeError, Error: err})
260+ return
261+ }
262+ }
263+ if err := ctx.Err(); err != nil && !sawFinish {
264+ _ = yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeError, Error: err})
259265 return
260266 }
261267 // flush any pending data