Skip to content

feat(tool runner): add support for server-side tools#1086

Merged
RobertCraigie merged 5 commits intoanthropics:nextfrom
karpetrosyan:feat-runners-allow-passing-tools-to-upstream
Dec 3, 2025
Merged

feat(tool runner): add support for server-side tools#1086
RobertCraigie merged 5 commits intoanthropics:nextfrom
karpetrosyan:feat-runners-allow-passing-tools-to-upstream

Conversation

@karpetrosyan
Copy link
Collaborator

No description provided.

@karpetrosyan karpetrosyan requested a review from a team as a code owner November 26, 2025 20:55
@karpetrosyan karpetrosyan marked this pull request as draft November 26, 2025 21:01
@karpetrosyan karpetrosyan force-pushed the feat-runners-allow-passing-tools-to-upstream branch 5 times, most recently from 779b28d to 2027f76 Compare December 1, 2025 19:40
@karpetrosyan karpetrosyan force-pushed the feat-runners-allow-passing-tools-to-upstream branch from 2027f76 to 134124b Compare December 1, 2025 20:16
@karpetrosyan karpetrosyan marked this pull request as ready for review December 1, 2025 21:21
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using BetaToolUnionParam should we only type it to allow server side tools? or rather, not allow client side tools?

I'm concerned about a footgun with surprising behaviour where a user passes in a normal client side tool without using our tool helpers, where if the model tries to call it, you'd probably get a weird error.

So another solution would be to make sure the error message in that case is helpful.

@karpetrosyan
Copy link
Collaborator Author

I'm concerned about a footgun with surprising behaviour where a user passes in a normal client side tool without using our tool helpers, where if the model tries to call it, you'd probably get a weird error.

How would a user pass the client side tools without using tool helpers? It is basically only possible with the tool helpers feature.

@RobertCraigie
Copy link
Collaborator

cause now you can do tool_runner(..., tools=[{'name': 'get_weather', 'type': 'custom', 'input_schema': ...}]) right?

@karpetrosyan
Copy link
Collaborator Author

Ah, I see now. The server tool use blocks have other types, not 'tool_use', so our tool runner doesn't see them. For example, the web search tool use block will send 'server_tool_use'

@RobertCraigie
Copy link
Collaborator

sorry no I mean that you could do this

    runner = client.beta.messages.tool_runner(
        max_tokens=1024,
        model="claude-3-5-sonnet-latest",
        tools=[{"name": "get_weather", "input_schema": {...}}],
        messages=[{"role": "user", "content": "What is the weather in SF?"}],
    )

which form the anthropic API perspective is the exact same as @beta_tool(), so it'll try to call that tool and then we'll get a weird error

@karpetrosyan
Copy link
Collaborator Author

In that case, the tool runner will send an error message as a tool call result back to Anthropic, and the user will probably see a final message from Anthropic saying that the user-provided tool wasn't successfully called. Would it be sufficient if we add a warning there, so it would be clear to the user that something is wrong?

Comment on lines +1325 to +1326
client_side_tools: list[BetaRunnableTool] = []
server_side_tools: list[BetaToolUnionParam] = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is a bit of a misnomer

Suggested change
client_side_tools: list[BetaRunnableTool] = []
server_side_tools: list[BetaToolUnionParam] = []
runnable_tools: list[BetaRunnableTool] = []
raw_tools: list[BetaToolUnionParam] = []

(not a big fan of raw_tools so fft come up with something else)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed
I'm ok with raw_tools, it's an internal naming so I wont think so much

@karpetrosyan karpetrosyan force-pushed the feat-runners-allow-passing-tools-to-upstream branch 2 times, most recently from e12ab18 to 4425c1a Compare December 3, 2025 17:49
@RobertCraigie RobertCraigie merged commit 1521316 into anthropics:next Dec 3, 2025
8 checks passed
@stainless-app stainless-app bot mentioned this pull request Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants