Repository navigation
fix(gemini): fail invalid function calls, end unfinished continuations - #4808
Open
jaeminbird wants to merge 1 commit into
Open
jaeminbird wants to merge 1 commit into
jaeminbird wants to merge 1 commit into
Conversation
Completes the remaining docker#4600 P2.1 terminal cases raised in the docker#4786 review. MALFORMED_FUNCTION_CALL and UNEXPECTED_TOOL_CALL now fail the stream with ErrInvalidFunctionCall instead of falling through to the inferred stop or tool_calls, so the turn can no longer end as an empty or apparently complete answer. A CONTINUATION stop, or a continuation token, that the SDK doesn't resume now ends the turn as length instead of stop. Any later finish reason clears it, so a resumed stream still ends as stop.
This branch has not been deployed
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.
Follow-up to #4786, covering the two P2.1 cases from #4600 that @aheritier flagged in review.
MALFORMED_FUNCTION_CALL/UNEXPECTED_TOOL_CALL: Gemini ends the turn without the call. On main this fell through to the inferred reason, so the turn ended as an emptynull, or asstopwhen text came first. It looked like a finished answer. The adapter now fails the stream withErrInvalidFunctionCall. modelerrors treats it as non-retryable, so a fallback model takes over if one is configured.CONTINUATION: SDK v1.77 continues automatically, but when it can't resume (no token, or a repeated token with no progress), the partial answer ended asstop. A pending continuation now ends the turn aslength. Any later finish reason clears it, so a resumed stream still ends asstop.Tests
LocalRuntimefixture (geminiintegration): 3 new cases fail on main; with the fix,lengthfor both continuation cases, an error event for the malformed call, 0 tool runs. Passed 20/20.go test ./pkg/model/provider/... ./pkg/runtime/... ./pkg/acp/... ./pkg/cli/...on Windows: onlyTestBackgroundWorktree*andTestFilesystemPolicyExpandsHomeDirectoryfail, same on main. golangci-lint clean. Not run on Linux this time.finishMessage, so the error carries only the reason there.