on main help sign in
fix: hyper provider cancel (#2133)
8adfe70Kujtim Hoxha
internal/agent/hyper/provider.go+10−4
@@ -252,10 +252,16 @@ func (m *languageModel) Stream(ctx context.Context, call fantasy.Call) (fantasy.
252 continue
252 continue
253 }
253 }
254 }
254 }
255− if err := scanner.Err(); err != nil &&
255+ if err := scanner.Err(); err != nil {
256− !errors.Is(err, context.Canceled) &&
257− !errors.Is(err, context.DeadlineExceeded) {
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 {
258− yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeError, Error: err})
264+ _ = yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeError, Error: err})
259 return
265 return
260 }
266 }
261 // flush any pending data
267 // flush any pending data