feat(provider/google): support cancelling long-running Interactions API agents via AbortSignal, and process their intermittent stream#15139
Merged
Conversation
…y could run for a long time otherwise
… include stream reasoning deltas there
lgrammel
approved these changes
May 11, 2026
Contributor
|
🚀 Published in:
|
github-actions Bot
added a commit
that referenced
this pull request
May 11, 2026
…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`.
Contributor
|
✅ Backport PR created: #15169 |
github-actions Bot
added a commit
that referenced
this pull request
May 11, 2026
…ractions API agents via AbortSignal, and process their intermittent stream (#15169) This is an automated backport of #15139 to the release-v6.0 branch. FYI @felixarntz --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Felix Arntz <felix.arntz@vercel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
streamTextagainst an agent buffered everything until the run finished instead of actually streaming.Summary
POST /interactions/{id}/cancelon abort.doStreamnow opensGET /interactions/{id}?stream=trueand reconnects withlast_event_idon idle disconnects.streamTextagent examples switched tofullStreamwith dimmedreasoning-deltaoutput; 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 tocancelled.Checklist
pnpm changesetin the project root)Future Work
webhook_config— deferred until the AI SDK has a fire-and-forget primitive; polling alongside a webhook defeats the point.background: truefor model-id calls — API rejects every documented model today, it seems the API only supports this parameter in combination withagent.