SWE-Rebench v2 hard task
harbor run -t ibragim-badertdinov/mozilla-ai__any-llm-1121harbor download ibragim-badertdinov/mozilla-ai__any-llm-1121OtariProvider drops cache control during Anthropic-to-OpenAI message conversion
any-llm version: 1.13.0 (current installed), also affects the otari provider module on main
Python version: 3.11
Describe the bug
OtariProvider extends BaseOpenAIProvider and inherits the default _amessages() implementation. That implementation calls messages_params_to_completion_params() which converts Anthropic Messages API format to OpenAI Chat Completions format before sending the request. During this conversion:
cache_control markers on system prompt content blocks are silently dropped — OpenAI format has no equivalent conceptthinking budget configuration is converted to reasoning_effort, which may not map cleanly for all upstream providersWhy this matters
Otari's gateway serves /v1/messages (Anthropic Messages API) natively, and that endpoint fully supports cache_control, thinking, and structured system prompts with caching. When clawbolt (or any other application using amessages()) routes through OtariProvider, every request loses prompt caching — which means higher latency, higher cost, and more cache misses. For applications that rely on Anthropic's extended-TTL prompt caching (1 hour), this is a significant regression.
Root cause
OtariProvider does not override _amessages(). The inherited method from AnyLLM._amessages() converts Anthropic format to OpenAI format, then sends via _acompletion():
amessages() → _amessages() → messages_params_to_completion_params() ← cache_control dropped here
→ _acompletion() → otari_client.completion() → /v1/chat/completions
Expected behavior
OtariProvider should override _amessages() to send Anthropic-format requests directly to otari's /v1/messages endpoint, preserving cache_control, thinking, and system prompt structure:
amessages() → OtariProvider._amessages() → raw HTTP POST to /v1/messages ← cache_control preserved
This requires either:
Option A: OtariProvider._amessages() sends Anthropic format to /v1/messages via raw httpx, bypassing the OpenAI SDK wrapper. Platform-mode auth (bearer token) and usage reporting still happen at this layer.
Option B: The otari SDK (AsyncOtariClient) adds a messages() method that talks to /v1/messages, then OtariProvider uses it. This keeps the platform protocol handling inside the otari SDK where it belongs.
Workaround
Until this is fixed, applications that need cache control can use the anthropic provider with api_base pointed at otari:
# Preserves cache_control, loses clean otari env var names
provider="anthropic",
api_base="https://api.otari.ai",
api_key="tk_<user_token>",
Example code to reproduce
from any_llm import amessages
response = await amessages(
model="claude-sonnet-4-5",
provider="otari",
api_base="https://api.otari.ai/v1",
api_key="tk_xxx",
system=[
{"type": "text", "text": "You are a helpful assistant.",
"cache_control": {"type": "ephemeral"}},
],
messages=[{"role": "user", "content": "Hello"}],
max_tokens=100,
)
# cache_control is silently dropped — the request to /v1/chat/completions
# has no cache markers, so the gateway never caches this content.
🤖 Generated by DeepSeek V4 Flash running on ds4
No new interfaces are introduced.