-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix: avoid Anthropic tool-history requests without tools #8248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
| // Restrict workaround to Anthropic/Claude routes to avoid unintended behavior changes. | ||
| const isAnthropicLike = | ||
| input.model.providerID === "anthropic" || | ||
| input.model.api.id.includes("anthropic") || | ||
| input.model.api.id.includes("claude") || | ||
| input.model.api.npm === "@ai-sdk/anthropic" | ||
|
|
||
| const effectiveTools: Record<string, Tool> = | ||
| isAnthropicLike && noToolsProvided && hasToolHistory | ||
| ? { | ||
| _dummy: tool({ | ||
| description: "Placeholder tool for API compatibility", | ||
| inputSchema: jsonSchema({ type: "object", properties: {} }), | ||
| }), | ||
| } | ||
| : tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a LOT of providers that don't have this issue... and having no tools is intentional...
ideally this would be strictly limited to litellm
Should not apply to anthropic, openrouter, vertex, bedrock, etc etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ik this is minor and most likely the llm wont call the dummy tool but I don't love this change affecting everyone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just make it if "litellm" in provider id (or similar)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reasonable, this is not for all. i will update for only "litellm".
What does this PR do?
Fixes Anthropic/LiteLLM proxies rejecting requests when message history contains tool calls but
toolsparam is empty.Adds a dummy tool when:
tool-callortool-resultThe dummy tool is excluded from
activeToolsso it won't be invoked.Fixes fix: Anthropic via LiteLLM/proxies rejects requests with tool history but no tools param #8246
Relates to LiteLLM error: Anthropic doesn't support tool calling without tools= param specified #2915
How did you verify your code works?
bun run tsc --noEmitpasses