Skip to content

Let built-in tools fallback on custom tools for models that don't support them #3212

@DouweM

Description

@DouweM

Description

Built-in tools are great, but specifying them on an agent currently limits you to using it only with models that support all of them, which makes it hard to use FallbackModel or try different models in evals.

It'd be great if you could specify a function tool (or toolset) to be used as a fallback when a built-in tool isn't available:

I imagine something like @agent.tool(fallback_for_builtin=WebSearchTool) (and similar on the Tool class). That would then be stored on the ToolDefinition, so that Model.prepare_request can look at the ModelRequestParameters.function_tools and .builtin_tools, check which are supported by the model in question (via new properties on self.profile: ModelProfile most likely), and then keep only one or the other. We'd only raise an error for unsupported built-in tools if no fallback was provided.

To support falling back from a built-in tool to a toolset (like with MemoryTool or MCPServerTool), we'd need a way to set this on a toolset as well, most likely when registering it on an agent rather than hard-coded on the toolset itself. With MCPServerTool, we'd also need to consider that a given MCPServer/FastMCPToolset would be a fallback for a specific MCPServerTool instance, not all MCPServerTools in general.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions