chore(deps): bump ai-sdk to v0.1.21

ai-sdk v0.1.21 wraps the cancellation cause in aborted-stream errors
("%w: %w") instead of formatting it, so errors.Is(err, context.Canceled)
is reliable again. The Telegram channel was compensating with a comment
explaining why errors.Is could not be trusted.

The code was already correct; only the comment was obsolete. It now
states the real reason for context.WithoutCancel(turnCtx): turnCtx is
dead on both stop and fault paths, so the cursor-drop edit needs a live
context. The runtime effect of the bump is that a /stop landing inside
the step loop is now logged as "chat turn stopped" rather than
"route failed".

Refs ai-sdk-0pn
This commit is contained in:
sam committed 2026-08-15 00:24:33 +10:00
1 parent 3fd672c999
commit 566beff1d6
3 files changed
+8 -9

No files matched your search

+1 -1
View File
@@ -72,7 +72,7 @@ require (
github.com/moby/moby/client v0.5.1
github.com/nats-io/nats-server/v2 v2.14.4
github.com/nats-io/nats.go v1.52.0
github.com/samcharles93/ai-sdk v0.1.20
github.com/samcharles93/ai-sdk v0.1.21
github.com/traefik/yaegi v0.16.1
golang.org/x/net v0.57.0
golang.org/x/term v0.45.0
+2
View File
@@ -128,6 +128,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/samcharles93/ai-sdk v0.1.20 h1:Z52dyMN293aV8Cpgjdyyd2zw6oNF5FSXKWfCuxY/3UA=
github.com/samcharles93/ai-sdk v0.1.20/go.mod h1:a4JYsUrwGsmm2eiXgrpcKExtYe7uHQ5zsHDbbkcPB6o=
github.com/samcharles93/ai-sdk v0.1.21 h1:V/OqLnoWuZQ/8qw6MiVZuQU5qVLkULGex6WMQYCbCg4=
github.com/samcharles93/ai-sdk v0.1.21/go.mod h1:a4JYsUrwGsmm2eiXgrpcKExtYe7uHQ5zsHDbbkcPB6o=
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+5 -8
View File
@@ -556,14 +556,11 @@ func (g *Gateway) submitTurn(ctx context.Context, b *bot.Bot, msg *models.Messag
// already streamed stays, minus the cursor that would otherwise
// claim the answer is still being written.
//
// Both failure branches abandon through a live context, not
// turnCtx. A /stop is not reliably reported as context.Canceled:
// ai-sdk raises an aborted stream as ErrAborted with ctx.Err()
// formatted in, not wrapped, so errors.Is misses a cancellation
// that landed inside the step loop or a tool call and it arrives
// here as a plain error -- with turnCtx already dead. Editing
// through a dead context fails, and the cursor this cleanup
// exists to remove would blink forever.
// errors.Is(err, context.Canceled) reliably separates a /stop from
// a fault, but turnCtx is dead either way, so the cursor-drop edits
// through context.WithoutCancel(turnCtx) -- a live context. A
// cancelled context would fail the edit and leave the cursor
// blinking on a message nothing will ever finish.
if err != nil {
if errors.Is(err, context.Canceled) {
g.log.Info("chat turn stopped", "session", session)