Skip to content

Backport: feat(provider/google): support cancelling long-running Interactions API agents via AbortSignal, and process their intermittent stream#15169

Merged
github-actions[bot] merged 2 commits into
release-v6.0from
backport-pr-15139-to-release-v6.0
May 11, 2026
Merged

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

This is an automated backport of #15139 to the release-v6.0 branch. FYI @felixarntz

…PI agents via AbortSignal, and process their intermittent stream (#15139)

## Background

PR #15013 added Interactions API support but two background-mode gaps
remained: aborting a call didn't stop the run on Google's side (kept
billing), and `streamText` against an agent buffered everything until
the run finished instead of actually streaming.

## Summary

- Poll loop now fires `POST /interactions/{id}/cancel` on abort.
- Agent `doStream` now opens `GET /interactions/{id}?stream=true` and
reconnects with `last_event_id` on idle disconnects.
- Existing `streamText` agent examples switched to `fullStream` with
dimmed `reasoning-delta` output; new abort examples + shared
SIGINT→AbortController helper.

## Manual Verification

- `aif
examples/ai-functions/src/stream-text/google/interactions-agent-single-turn.ts`
— reasoning prints incrementally.
- `aif
examples/ai-functions/src/generate-text/google/interactions-agent-abort.ts`
— server-reported status flips to `cancelled`.

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Future Work

- `webhook_config` — deferred until the AI SDK has a fire-and-forget
primitive; polling alongside a webhook defeats the point.
- `background: true` for model-id calls — API rejects every documented
model today, it seems the API only supports this parameter in
combination with `agent`.
try {
while (true) {
if (abortSignal?.aborted) {
await cancelOnServer();
Copy link
Copy Markdown
Contributor

@vercel vercel Bot May 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the abort signal is already aborted at the top of the polling loop, cancelOnServer() is called twice: once explicitly before throwing the DOMException, and again in the catch block that catches the same DOMException.

Fix on Vercel

@github-actions github-actions Bot merged commit b3642fe into release-v6.0 May 11, 2026
17 checks passed
@github-actions github-actions Bot deleted the backport-pr-15139-to-release-v6.0 branch May 11, 2026 18:39
@github-actions
Copy link
Copy Markdown
Contributor Author

🚀 Published in:

Package Version
@ai-sdk/google 3.0.72
@ai-sdk/google-vertex 4.0.126
@ai-sdk/mcp 1.0.42

@felixarntz felixarntz added the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 13, 2026
github-actions Bot added a commit that referenced this pull request May 13, 2026
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

⚠️ Backport to release-v5.0 created but has conflicts: #15252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant