feat: modern function-calling config — validated mode, allowed functions, call ID round-trip - #71
Open
PandelisZ wants to merge 1 commit into
Open
Conversation
flachesis
approved these changes
Jun 28, 2026
PandelisZ
force-pushed
the
pz/chonkyllm-gemini-modern-fc-pr
branch
from
June 30, 2026 13:55
29d30d7 to
84d5968
Compare
- FunctionCallingMode enum: Auto/Any/None/Validated (SCREAMING_SNAKE_CASE wire format)
- FunctionCallingConfig: mode + optional allowed_function_names
- ToolConfig wrapper that serialises to {functionCallingConfig: {...}}
- FunctionCall.id + FunctionResponse.id for stable call/response matching
- tool_config() builder method on GenerationRequest
- Re-export ToolConfig, FunctionCallingConfig, FunctionCallingMode from lib.rs
- Tests: validated mode wire shape, function call ID round-trip,
function response ID round-trip, Content::function_call helper
PandelisZ
force-pushed
the
pz/chonkyllm-gemini-modern-fc-pr
branch
from
June 30, 2026 13:59
84d5968 to
9c1daed
Compare
Contributor
Author
|
Hi @flachesis Thanks for the approval. I saw you merged in main and the CI failed so I've rebased on master and fixed the issues. So this is now mergable and re-tested. I hope that helps and feel free to merge when you're happy with it |
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.
What this adds
Support for the current Gemini function-calling API contract as documented at https://ai.google.dev/gemini-api/docs/function-calling.
Three gaps existed in the library that made it impossible to use the modern Gemini function-calling surface correctly:
functionCallingConfig— the model always usedAUTOmode implicitly.allowedFunctionNames— callers couldn't restrict or force a specific function.FunctionCallandFunctionResponsehad noidfield — Gemini attaches a stable ID to each call; without round-tripping it back in the response the API rejects multi-turn and parallel tool-call flows.Changes
src/tools/model.rsFunctionCallingModeenum with variantsAuto/Any/None/Validated, serialising to Gemini'sSCREAMING_SNAKE_CASEwire format.FunctionCallingConfigstruct:mode+allowed_function_names: Option<Vec<String>>.ToolConfigwrapper that serialises to{"functionCallingConfig": {...}}.FunctionCall.id: Option<String>— preserves the ID Gemini attaches to each call.FunctionResponse.id: Option<String>— must echo back the matching call ID.FunctionCall::with_id(),FunctionResponse::with_id().src/generation/builder.rsGenerationRequestgainstool_config: Option<ToolConfig>(serialised astoolConfig)..tool_config(config)builder method.src/lib.rsRe-exports
ToolConfig,FunctionCallingConfig,FunctionCallingModefrom the crate root.src/tests.rsNew unit tests:
test_tool_config_serializes_validated_mode_and_allowed_function_names— verifies the exact JSON wire shapetest_function_call_with_id_serialization— round-tripsFunctionCall.idtest_function_response_with_id_serialization— round-tripsFunctionResponse.idtest_multi_turn_content_structureto verifyContent::function_call_with_thoughtpropagatesthoughtSignatureto the PartUsage example
All 11 existing + new unit tests pass.