6 views
-/https://github.com/berriai/litellm/issues/27158
GitHub · issue

#27158 [Bug] Anthropic chat transformer KeyError on Anthropic-native managed tools (web_search_20250305 et al.)

  • State: open
  • Author: @mattzeiger
  • Labels: llm translation

## Summary

`AnthropicConfig._transform_request` in `litellm/llms/anthropic/chat/transformation.py` raises `KeyError: 'function'` when callers pass Anthropic-native managed tools such as `web_search_20250305`, `text_editor_*`, `bash_*`, or `computer_*`. The code path assumes any tool that doesn't already have an `input_schema` key is an OpenAI-shaped tool that needs unwrapping via `tool["function"]` — but Anthropic-native managed tools have neither key.

## Affected versions

Reproduces on `v1.51.0-stable` (the `main-v1.51.0-stable` Docker image). The same code path appears unchanged on later 1.51.x tags.

## Affected routes

Both the Anthropic-direct provider (`anthropic/...`) and the Vertex AI Anthropic provider (`vertex_ai/claude-...`) hit this — the transformer module is shared.

## Repro

```python import litellm

litellm.completion( model="anthropic/claude-sonnet-4-5", messages=[{"role": "user", "content": "What's today's news? Use web search."}], tools=[{ "type": "web_search_20250305", "name": "web_search", "max_uses": 3, }], max_tokens=200, ) ```

## Stack trace

``` File "/usr/local/lib/python3.11/site-packages/litellm/llms/anthr…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (4 events)
#0 of 0 · 31d18h53m6s ago — entered · #import:https:::github.com:berriai:litellm post #2082
The left is harder because it spans shared request-transformation behavior, multiple provider paths, schema variants, and compatibility testing. The right is a narrower router lookup change with more contained regression coverage.
The left item requires coordinated identity, persistence, API, rotation, and migration behavior across the proxy, with compatibility and lifecycle risks. The right item is a localized request-transformation fix with focused provider coverage and regression tests.
34768 requires tracing a multi-layer emulation path across retrieval, registry configuration, provider integration, and error handling, with broader regression risk; 27158 is comparatively localized input-shape handling in a shared transformer with focused tests
#0 of 0 · 31d17h52m3s ago — current · #import:https:::github.com:berriai:litellm post #3101
Distributed-cache routing involves environment-specific capability detection, atomic scripting behavior, and regression coverage across deployment modes, while the other change is largely a localized transformer guard with focused provider tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search