Add provider-specific settings to native tools
- Closes #7338
First of three stacked PRs: this one adds the mechanism, #12610 adds Anthropic's options on top, and #7807 deprecates the old single-provider fields.
What this adds
WebSearchTool and AdvisorTool get a provider_settings field for options only one provider has. Each model reads only its own entry, so one tool definition can carry settings for several providers.
WebSearchTool(provider_settings={'openrouter': {'engine': 'exa', 'max_results': 5}})
New options: OpenRouter search engine, mode, max_results, max_total_results and max_characters; OpenRouter advisor forward_transcript.
Does user behaviour change?
Not for existing code. Nothing changes unless you set one of the new options.
- OpenRouter's advisor still defaults to
forward_transcript=False. Setting it toTrueis now possible. - Unknown keys and options in
provider_settingsare ignored, like model settings. Type checkers flag typos through theTypedDicts. At runtime each model reads only the options it knows from its own entry, so an unknown one is never sent and can't override a field likeallowed_domains. Whether a value is one the provider accepts stays with its API, so an engine OpenRouter adds later works without a release.
Testing
A recorded OpenRouter cassette covers engine and max_results, including the url_citation annotations that come back. A test table sends every new option through a real mocked request and fails if an option has no entry. I also ran live calls against OpenRouter.
To check for regressions, I ran about 2,100 mocked checks on both main and this branch, before the Anthropic part moved to #12610: every tool field across each adapter and client, and every capability argument. The only difference was the new exported names. Moving the Anthropic part out only removed code.
Checklist
- Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver. (Not applicable.)
- PR title is fit for the release changelog.
š¤ Generated with Claude Code