Skip to content

Claude models behind OpenAI-compatible proxies get 400 prefill errors #20415

Description

@bussnet

Bug

Claude models routed through non-native SDK paths (@ai-sdk/openai-compatible, GitHub Copilot, Azure AI / LiteLLM) fail with:

[400]: This model does not support assistant message prefill.
The conversation must end with a user message.

This is likely the shared root cause behind #19517 and #13768.

Root Cause

ProviderTransform in transform.ts uses three different conditions to detect Claude models, and they disagree:

Transform Condition Lines
Empty content stripping api.npm === "@ai-sdk/anthropic" L56
Tool call ID scrubbing api.id.includes("claude") L76
Prompt caching providerID || api.id || model.id || api.npm L282-287

When a Claude model uses any SDK other than @ai-sdk/anthropic — proxies, Copilot, Azure AI — caching activates but empty-content stripping does not. Empty assistant messages survive, get cache metadata, and Anthropic rejects them as prefill.

Reproduction

  1. Configure a Claude model through an OpenAI-compatible proxy with a model name containing "claude"
  2. Use it in a multi-agent conversation with tool calls
  3. After several turns, the request fails with the prefill error

Fix

PR #20414 — extracts isClaudeModel() helper used at all three detection sites.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions