🎯 Changes#
Follows #2183, which did the same for Mistral.
The Gemini text adapter ended every finish reason other than MAX_TOKENS and the content-filter set as RUN_FINISHED with stop. When Gemini finishes a turn with MALFORMED_FUNCTION_CALL (it could not form the function call) or LANGUAGE (unsupported language), the chunk has no text and no tool call. The run then looks like a normal stop, and an agent loop ends with no output and no error.
These two finish reasons now end the run with a RUN_ERROR (codes malformed_function_call and language). The error carries usage and no RUN_FINISHED follows, the same way MAX_TOKENS already works and like the Mistral adapter handles its error finish reason. OTHER stays a normal stop, as the existing test requires. docs/adapters/gemini.md lists the two new codes next to max_tokens.
Test plan#
The @tanstack/ai-gemini vitest suite (68 tests) passes with the change; the full pnpm run test:pr was not run. It includes the new parameterized test in tests/gemini-adapter.test.ts. It streams a chunk with each finish reason and checks for a RUN_ERROR with the right code and usage, and no RUN_FINISHED. Both cases fail without the change in src/adapters/text.ts.
✅ Checklist#
🚀 Release Impact#
This pull request was prepared with the assistance of an AI agent (Claude).
Summary by CodeRabbit#
- Bug Fixes
- Gemini responses ending with
MALFORMED_FUNCTION_CALL or LANGUAGE now report an error instead of indicating successful completion. The error includes usage information and a reason-specific code.
View your CI Pipeline Execution ↗ for commit 4e5da6ecd816d82c85a653490378d071a3ba0b9d
nx affected --targets=test:sherif,test:knip,tes...nx run-many --targets=build --exclude=examples/...nx run-many --targets=test:coverage --projects=...💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗
☁️ Nx Cloud last updated this comment at
2026-11-30 09:19:40UTC