fix(ai-gemini): report failed or cancelled agentic video interactions as RUN_ERROR #2310
main fromrefs/pull/2310/head·opened View on GitHub🎯 Changes#
Follows #2234: the same class of bug (a provider status ignored and reported as success), here in the agentic video path.
GeminiTextAdapter.interactionsStream (the agentic video path) ignored interaction.status. When Gemini marked the interaction failed or cancelled, the adapter still emitted TEXT_MESSAGE_* with an empty output_text and closed the run with RUN_FINISHED / finishReason: 'stop', so callers saw a successful empty answer.
The stream now checks the status right after interactions.create and, for failed or cancelled, emits RUN_ERROR (code set to the status, usage if present) and stops. This matches what the experimental text-interactions adapter already does for the same statuses.
Docs: docs/adapters/gemini-advanced.md (Agentic understanding) now says that a failed or cancelled interaction ends the run with RUN_ERROR and that code, not RUN_FINISHED.
Tests:
- Unit:
it.each(['failed', 'cancelled'])inpackages/ai-gemini/tests/agentic-video.test.ts, run for both models. Fails on main (4 failed, 6 passed), passes with this change (10 passed); full ai-gemini suite passes (526). - e2e:
testing/e2e/tests/video-understanding.spec.tsgets a failed and a cancelled case. The/vu-interactionsaimock mount returns afailed/cancelledinteraction when the prompt carries a marker, and the spec asserts the chat stream containsRUN_ERRORwith the status ascodeand noRUN_FINISHED. Run withE2E_PROVIDERS=gemini: 2 failed on main's adapter, 3 passed with the fix.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
- Docs: I updated
docs/for this change, or this change is not user-facing. - Changeset: I added a changeset (
pnpm changeset), or this PR does not change a published package.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
This change was prepared with the help of an AI coding assistant (Claude).
Summary by CodeRabbit#
- Bug Fixes
- Failed or cancelled video-understanding interactions now emit a run error with the matching status instead of being reported as successfully finished.
- Documentation
- Clarified how failed and cancelled interaction statuses are handled.
- 1
tanstack-source added labelsbug
This looks useful. It follows the same pattern as #2234. The pull request does not link an issue.
TanStack Source bot, value agent
No actionable comments were generated in the recent review.
Walkthrough
-
The Gemini text adapter now emits
RUN_ERRORwhen an interaction has afailedorcancelledstatus. Unit tests and end-to-end tests cover both statuses.Changes: Gemini interaction status handling
Layer / File(s) Summary Handle failed and cancelled statuses
packages/ai-gemini/src/adapters/text.ts,packages/ai-gemini/tests/agentic-video.test.ts,docs/adapters/gemini-advanced.md,.changeset/gemini-agentic-video-status.mdThe adapter emits RUN_ERRORwith the interaction status as its code and includes usage when available. Unit tests cover both statuses. The documentation and changeset describe the behavior.Exercise statuses in end-to-end tests
testing/e2e/global-setup.ts,testing/e2e/tests/video-understanding.spec.tsThe E2E mock returns failed or cancelled statuses for matching request markers. Tests assert RUN_ERRORand noRUN_FINISHED.Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Suggested reviewers:
jherr,tombeckenham,alemtuzlak
Merge Risk:
Minimal · up to93599-
Failed or cancelled Gemini agentic video interactions now surface as errors instead of appearing to finish successfully. The change has unit and end-to-end coverage and no remaining merge-blocking risk was identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: agentic video interactions with failed or cancelled status now report RUN_ERROR in @tanstack/ai-gemini. The changeset, adapter code, docs, and tests all match this. Th…Description check The description follows the template sections: Changes, Checklist, and Release Impact. The Changes section explains the bug, the fix, the docs update, and the unit and e2e tests with run results. Chec… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title names the main change: agentic video interactions with failed or cancelled status now report RUN_ERROR in
@tanstack/ai-gemini. The changeset, adapter code, docs, and tests all match this. The title is specific and follows the fix(scope) convention.
Full details: Description check
-
Explanation
The description follows the template sections: Changes, Checklist, and Release Impact. The Changes section explains the bug, the fix, the docs update, and the unit and e2e tests with run results. Checklist items are marked for contributing guide, docs, and changeset. The unchecked box for running pnpm run test:pr is left unmarked with no stated reason, since the author reports targeted test runs but not the full pr test command. The author also left the 'I fully understand the code' box unchecked while noting AI assistance, which is a template item the author should confirm.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/ai
- Branch: main
- File: .coderabbit.yaml
- Commit: 840ea56
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b8810ee4-df03-447e-810b-11f930d10c7d
Commits-
Reviewing files that changed from the base of the PR and between 840ea56621f4c32de4359849a0beaa343db60fe3 and 935992263aa66c4ed111795ac50043982ba66cbc.
Files selected for processing: 6-
.changeset/gemini-agentic-video-status.mddocs/adapters/gemini-advanced.mdpackages/ai-gemini/src/adapters/text.tspackages/ai-gemini/tests/agentic-video.test.tstesting/e2e/global-setup.tstesting/e2e/tests/video-understanding.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
-
github-actions[bot](GitHub profile, opens in a new tab) assignedtombeckenham
Thanks for the PR, @pcbeingused33! 🙌 @tombeckenham will take a look.
Automated pre-review checks
- ✅ CI passing
- ✅ No merge conflicts
- ✅ Changeset present
- ✅ E2E test changes included
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 935992263aa66c4ed111795ac50043982ba66cbc
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR