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

+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)