Skip to content

Conversation

@seilk
Copy link

@seilk seilk commented Jan 13, 2026

What does this PR do?

Fixes Anthropic/LiteLLM proxies rejecting requests when message history contains tool calls but tools param is empty.
Adds a dummy tool when:

How did you verify your code works?

  • bun run tsc --noEmit passes
  • Tested with LiteLLM gateway: tool-history requests now succeed
  • Existing tests unaffected (557 pass, 95 fail - same as baseline)

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Comment on lines +160 to +175
// 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
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

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)

Copy link
Author

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Anthropic via LiteLLM/proxies rejects requests with tool history but no tools param

3 participants