Skip to content

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

Merged
felixarntz merged 8 commits into
mainfrom
fa/gemini-interactions-background
May 11, 2026
Merged

feat(provider/google): support cancelling long-running Interactions API agents via AbortSignal, and process their intermittent stream#15139
felixarntz merged 8 commits into
mainfrom
fa/gemini-interactions-background

Conversation

@felixarntz
Copy link
Copy Markdown
Collaborator

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

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • 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.

@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 8, 2026
@felixarntz felixarntz merged commit db394ab into main May 11, 2026
19 checks passed
@felixarntz felixarntz deleted the fa/gemini-interactions-background branch May 11, 2026 14:03
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.0-canary.131
@ai-sdk/alibaba 2.0.0-canary.47
@ai-sdk/amazon-bedrock 5.0.0-canary.57
@ai-sdk/angular 3.0.0-canary.131
@ai-sdk/anthropic 4.0.0-canary.51
@ai-sdk/assemblyai 3.0.0-canary.40
@ai-sdk/azure 4.0.0-canary.55
@ai-sdk/baseten 2.0.0-canary.45
@ai-sdk/black-forest-labs 2.0.0-canary.39
@ai-sdk/bytedance 2.0.0-canary.40
@ai-sdk/cerebras 3.0.0-canary.45
@ai-sdk/cohere 4.0.0-canary.41
@ai-sdk/deepgram 3.0.0-canary.39
@ai-sdk/deepinfra 3.0.0-canary.45
@ai-sdk/deepseek 3.0.0-canary.42
@ai-sdk/elevenlabs 3.0.0-canary.39
@ai-sdk/fal 3.0.0-canary.39
@ai-sdk/fireworks 3.0.0-canary.45
@ai-sdk/gateway 4.0.0-canary.77
@ai-sdk/gladia 3.0.0-canary.39
@ai-sdk/google 4.0.0-canary.59
@ai-sdk/google-vertex 5.0.0-canary.78
@ai-sdk/groq 4.0.0-canary.42
@ai-sdk/huggingface 2.0.0-canary.45
@ai-sdk/hume 3.0.0-canary.39
@ai-sdk/klingai 4.0.0-canary.40
@ai-sdk/langchain 3.0.0-canary.131
@ai-sdk/llamaindex 3.0.0-canary.131
@ai-sdk/lmnt 3.0.0-canary.39
@ai-sdk/luma 3.0.0-canary.39
@ai-sdk/mcp 2.0.0-canary.47
@ai-sdk/mistral 4.0.0-canary.43
@ai-sdk/moonshotai 3.0.0-canary.45
@ai-sdk/open-responses 2.0.0-canary.41
@ai-sdk/openai 4.0.0-canary.55
@ai-sdk/openai-compatible 3.0.0-canary.45
@ai-sdk/otel 1.0.0-canary.77
@ai-sdk/perplexity 4.0.0-canary.42
@ai-sdk/prodia 2.0.0-canary.42
@ai-sdk/provider-utils 5.0.0-canary.38
@ai-sdk/react 4.0.0-canary.132
@ai-sdk/replicate 3.0.0-canary.40
@ai-sdk/revai 3.0.0-canary.40
@ai-sdk/rsc 3.0.0-canary.132
@ai-sdk/svelte 5.0.0-canary.131
@ai-sdk/togetherai 3.0.0-canary.45
@ai-sdk/valibot 3.0.0-canary.38
@ai-sdk/vercel 3.0.0-canary.45
@ai-sdk/voyage 2.0.0-canary.13
@ai-sdk/vue 4.0.0-canary.131
@ai-sdk/workflow 1.0.0-canary.47
@ai-sdk/xai 4.0.0-canary.58

@gr2m gr2m added backport Admins only: add this label to a pull request in order to backport it to the prior version and removed backport Admins only: add this label to a pull request in order to backport it to the prior version labels May 11, 2026
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`.
@github-actions
Copy link
Copy Markdown
Contributor

✅ Backport PR created: #15169

@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 11, 2026
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>
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.

3 participants