Repository navigation
fix(py): stop Gemini tool-calling loops and log failed GenkitError turns - #107
Merged
Merged
Conversation
huangjeff5
force-pushed
the
fix/py-day1-tools-schema-and-failed-turn-log
branch
2 times, most recently
from
November 11, 2026 21:58
380c040 to
fa133c7
Compare
huangjeff5
force-pushed
the
fix/py-day1-tools-schema-and-failed-turn-log
branch
from
November 11, 2026 22:39
fa133c7 to
3bda1a5
Compare
huangjeff5
added a commit
that referenced
this pull request
Nov 11, 2026
…and document custom.candidates
huangjeff5
force-pushed
the
fix/py-day1-tools-schema-and-failed-turn-log
branch
from
November 11, 2026 22:43
3bda1a5 to
7cf32c6
Compare
apascal07
approved these changes
Nov 11, 2026
…ing Gemini models
huangjeff5
added a commit
that referenced
this pull request
Nov 12, 2026
…uickstart Keeps main's GEMINI_FLASH_LATEST (no constrained output with tools, #107) over this branch's copy of 3.5 Flash supports, and moves the unknown-model fallback test case off gemini-3.5-flash-lite, which this branch catalogs.
This was referenced Nov 15, 2026
Merged
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.
ai.generate()withtools+output_schemaortool_choice='required'no longer loops 50 turns or fails with400/504, and failed turns now log one error line to stderr instead of exiting silently. Withouttools, every Gemini and Gemma text model continues to use native wireresponse_json_schema.Main Changes
tools+output_schemaare paired on incompatible models: Withouttools, every Gemini and Gemma text model uses nativeresponse_json_schema. Whentoolsare attached alongsideoutput_schema:ConstrainedSupport.ALL(nativeresponse_json_schema+tools):gemini-4-carbon,gemini-4-argon,gemini-3.1-*,gemini-pro-latest,gemini-3-flash-preview,gemini-3.5-*,gemini-3.6-flash,gemini-flash-lite-latest, Vertex tuned endpoints, and any newgemini-4-*+ IDs.ConstrainedSupport.NO_TOOLS(native JSON without tools; prompt-injected schema only whentoolsare passed):gemini-2.5-*(which HTTP-400s ontools+ JSON mode),gemini-3.7/3.8-flash/gemini-flash-latest(which loop tool calls or504), andgemma-*. Passingoutput_constrained=Falseforces the same prompt-injection fallback per call on any model.tool_choice='required'relaxes fromANYtoAUTOafter a tool answers: Gemini'sANYmode forbids text replies and HTTP-400s next toresponse_mime_type='application/json'. Turn 1 sendsANYwithout JSON mode to guarantee the tool call; once a tool response arrives, follow-up turns relax toAUTOso the model can emit its final answer.GenkitErrors boxed ontores.error(bad key, missing key, unknown model ID) previously logged nothing, soprint(res.text)printed an empty line and exited0.log_dropped_failurenow logs one line (no traceback, no prompt text) for every non-PublicErrorfailure.Breaking changes
None.