Skip to content

Google GenAI sampling handler treats opaque tool-use IDs as function names #5551

Description

@mikamikasuki

What happened?

When the sampling history contains a valid opaque tool-use ID, GoogleGenaiSamplingHandler derives the Gemini function name from that ID instead of matching it to the preceding ToolUseContent.name.

For example, a call with id="call_opaque_123" and name="lookup_customer" becomes a function call named lookup_customer, but its paired ToolResultContent(tool_use_id="call_opaque_123") becomes a FunctionResponse named call_opaque. Gemini requires FunctionResponse.name to identify the declared function. IDs generated in FastMCP's private {function_name}_{uuid8} format pass; valid IDs that do not follow that format expose the mismatch.

The MCP sampling contract carries the ID and function name separately and matches a result to a call by ID (SEP-1577). Could the handler resolve each result ID against its paired tool-use block when building the Gemini response? Sampling was deprecated in protocol version 2026-07-28; this affects users of the existing FastMCP handler.

Example Code

Version Information

- FastMCP main: `5baeacfe20eca735cb949564b4915f93a622b916`
- Python: 3.12.15
- OS: macOS 15.0.1 arm64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.clientRelated to the FastMCP client SDK or client-side functionality.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions