Repository navigation
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
edelauna
left a comment
There was a problem hiding this comment.
had a question on the logic for getting the model to continue / go on
| // Vertex rejects requests that end with a model turn, which can occur when | ||
| // resuming after an interrupted response. Preserve that turn and explicitly | ||
| // ask the model to continue rather than dropping conversation history. | ||
| if (this.isVertex && contents.at(-1)?.role === "model") { |
There was a problem hiding this comment.
This guard keys only on role === "model", not the trailing part type -- so if the last model turn ends with an unanswered functionCall (interrupted mid-tool-call), appending a plain-text Continue. turn breaks Gemini's functionCall->functionResponse pairing and Vertex 400s again. Task.ts normalizes dangling tool_use on the UI resume path, so is a functionCall-ending turn still reachable here (condensation, cross-model import)? If so, detect a trailing functionCall and synthesize a functionResponse instead of text.
There was a problem hiding this comment.
Good catch — yes, a functionCall-ending turn is still reachable here: Task.ts's normalization only covers the UI resume path, while condensed history and cross-model imports can hand this handler a conversation that ends in an unanswered tool call, so the request layer is the right place to close the gap.
Updated in f64b508: the guard now inspects the trailing model turn's parts instead of keying only on role === "model". If it contains unanswered functionCall parts, we append a user turn of synthesized functionResponse parts — one per call, name taken from the functionCall part itself, with the payload in the same { name, response: { name, content } } shape convertAnthropicContentToGemini produces for real tool results — instead of the plain-text Continue. turn. Model turns that end in plain text keep the existing Continue. behavior.
Added a test for the interrupted-mid-tool-call case that asserts the request contents pair the trailing functionCall (name read_file) with a synthesized functionResponse of the same name. All 10 vertex.spec.ts tests pass, along with the full pnpm test suite, ESLint, and tsc --noEmit.
PR Review: [Fix] Vertex Gemini requests fail when resuming model turnsThanks for this fix! Summary & Validation
Suggestions / Observations
LGTM! 🚀 |
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Required CI passed. Waiting for automated review of the latest commit. If automated review does not start, a maintainer must restart it. Review-state labels are managed by this workflow; do not edit them manually. |
|
This PR has been awaiting author changes for 14 days and will be automatically closed in 7 days. Please address the review comments or leave a comment if you need more time. |
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
This PR has had no activity for 60 days and will be automatically closed in 7 days unless there is new activity. If you'd like to continue, please rebase and leave a comment. |
What changed
Vertex Gemini requests now preserve assistant history while adding a minimal user continuation when converted conversation content would otherwise end with a model turn. Focused request-level tests cover the reported
gemini-3.7-flashfailure and verify that already-valid user-ending histories are unchanged.Why this change was made
Vertex AI rejects Gemini requests that end with a model turn, causing resumed tasks to fail with
Requests ending with a model turn are not supported. The direct Gemini provider tolerates this shape, so the compatibility handling is intentionally limited to Vertex.Impact
Users can resume Gemini 3.7 tasks through Vertex AI without receiving the 400 invalid-argument error, while prior assistant and tool-call context remains intact.
Closes #1287
Related PRs