Repository navigation
gateway: honor allowed-tool subsets from Gemini ANY and Responses allowed_tools - #164
Merged
Merged
Conversation
Add support for allowed function names in ANY requests.
Owner
|
@charan-rathore 感谢!我把 两个不阻塞的后续建议,欢迎再提 PR:
|
This was referenced Sep 28, 2026
This was referenced Sep 28, 2026
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.
Summary
Two request formats can restrict which tools the model may call, but the gateway used to forward every offered tool:
functionCallingConfigwithmode: "ANY"and a nonemptyallowedFunctionNameslist now forwards only the named declarations. One allowed name keeps its forced-choice behavior.tool_choice: {"type":"allowed_tools", ...}now readsmodeand the allowed function list, forwarding only those functions. It also keeps a namespaced function's mapping when that function is allowed, and does not forward an unlisted web search tool.String and named-function choices keep their previous behavior. Table-driven offline tests cover restricted and unrestricted choices, a namespaced function, and what Chat, Responses, Anthropic, and Code Assist send upstream.
Instinct assisted with the change and tests. No cloud keys or model calls were used.
Tests
go test ./internal/gateway -run '^(TestParseResponsesAllowed|TestParseGeminiAllowed)' -count=1go test ./internal/gateway -count=1git diff --check