[Platform][Anthropic] Support server-side tools via server_tools option#2196
[Platform][Anthropic] Support server-side tools via server_tools option#2196soyuka wants to merge 1 commit into
Conversation
…option Server tools (e.g. web_search) are fully-formed Anthropic specs appended verbatim to the request tools array, so the bridge stays forward-compatible with any server tool without a name-to-type mapping. Merged before the cache-control block so they join the cached tools prefix and tool_choice:auto.
|
Hey @soyuka, thanks for that - let's use to sort the situation a bit - thinking out loud here:
on the one hand i feel like adopting i think i would appreciate to streamline docs for promoting cc @valtzu |
|
I can document that if needed lmk. |
|
It would be nice to have some abstraction so that the same would work for any platform that supports the feature. Then it would be very similar to capabilities, or maybe we could even use capabilities? E.g. a model would have Then you'd have ai:
platform:
antropic:
# ..
server_tools:
web_search: true
gemini:
# ..
server_tools:
web_search: true
failover:
anthropic_to_gemini:
platforms:
- 'ai.platform.anthorpic'
- 'ai.platform.gemini'and then do the routing & constructing the request instead of current pass-through as-is. For simple things like web search and code execution having the platform-specific config in yaml is not an issue, but some server tools take input (e.g. location-based ones) so for those its usually not feasible to have them within platform config, and by putting them into code you make the code platform-specific, which may be unacceptable in failover setups. And of course it must still be possible to define platform-specific tools (in a pass-thru manner), not to handcuff people from using the latest features that have not yet landed on I understand this may be a stretch. |
Adds a
server_toolsoption to the AnthropicModelClient. Server-side (Anthropic-hosted) tools such asweb_searchare fully-formed Anthropic tool specs that must be passed through verbatim rather than mapped from a name. Each entry is appended to the requesttoolsarray, so the bridge stays forward-compatible with any future server tool without a name-to-type mapping.Merging happens before the existing cache-control block, so server tools join the cached tools prefix and are covered by
tool_choice: auto.The transport-only
server_toolskey is stripped before the request body is sent. Tests cover appending with and without function tools, cache-control placement on the last tool, and key removal.