Skip to content

Conversation

@marcellmars
Copy link

I needed to combine a custom Genkit tool with recent FileSearch RAG feature. It fits naturally.

It didn’t work, and I eventually realized that ai.WithTools() was overwriting any tools provided via config.Tools instead of merging them. Silently.

The fix was simple replacing gcc.Tools = tools with gcc.Tools = mergeTools(append(gcc.Tools, tools...))
and the built-in tools (FileSearch, GoogleSearch, CodeExecution, Retrieval) remain intact when adding custom tools.

After making the change, I found out that the Gemini API currently doesn’t allow mixing built-in tools with custom (tools) function calling at all:

Error 400: Tool use with function calling is unsupported

Unfortunate, but hopefully temporary.

Once this pull request is merged:

  • the SDK will report a clear API error instead of silently dropping tools
  • the code will be ready the moment Google enables the natural fit of tools working together
  • the Go SDK will match the JS SDK’s behavior, which already merges tools. Here's the test:

it('constructs tools array correctly', async () => {

Testing

  • Added TestToolMerging to verify the merge behavior
  • Updated the live test to document and expect the API limitation

@google-cla
Copy link

google-cla bot commented Nov 29, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the go label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant