Fix repeated stream finishes and preserve cancellation causes

This commit is contained in:
sausheong committed 2026-09-10 16:34:12 +08:00
1 parent 3170b28251
commit 019a38f111
5 files changed
+68 -2

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package runtime
import (
"context"
"errors"
"testing"
)
func TestSteeringPreservesProtocolCancellationCause(t *testing.T) {
cause := errors.New("duplicate tool call ID")
ctx, cancel := context.WithCancelCause(context.Background())
cancel(cause)
ctx = WithSteering(ctx, func(context.Context) (*SteeringMessage, error) { t.Fatal("called after cancellation"); return nil, nil })
_, err := (&Runtime{}).applySteering(ctx, nil)
if !errors.Is(err, cause) {
t.Fatalf("lost cause: %v", err)
}
}