Skip to content

Azure AI Foundry: Anthropic models (Claude) generate incorrect URLs and fail conversation compacting #9352

@woter1832

Description

@woter1832

Before submitting your bug report

Relevant environment info

- OS: Windows 11 25H2
- Continue version: v1.2.11
- IDE: VS Code 1.107.11
- Model: Claude Sonnet 4.5 via Azure AI Foundry
- Target URI from Azure portal: `https://resource.services.ai.azure.com/anthropic/v1/messages`

Description

Azure AI Foundry hosts multiple model providers (Anthropic, DeepSeek, Meta, etc.), each with their own API formats. Currently, Continue only supports Azure OpenAI Service format.

Problem 1: Wrong URL Construction

When using provider: azure with apiType: azure-foundry for Anthropic models (Claude), Continue generates:

https://resource.services.ai.azure.com/anthropic/v1/chat/completions?api-version=2023-07-01-preview

But Azure AI Foundry Anthropic endpoint should be:

https://resource.services.ai.azure.com/anthropic/v1/messages

Problem 2: Conversation Compacting Fails

Workaround of using provider: anthropic with Azure URL works for basic chat, but conversation compacting fails with:

messages.16: `tool_use` ids were found without `tool_result` blocks immediately after

Azure validates tool_use/tool_result message pairing more strictly than direct Anthropic API.

Proposed Solution

Modify Azure.ts to detect provider format based on model name:

protected getProviderFormat(): "openai" | "anthropic" {
  const model = this.model.toLowerCase();
  
  if (model.includes("claude")) {
    return "anthropic";
  }
  
  if (model.includes("gpt") || model.includes("o1") || model.includes("o3")) {
    return "openai";
  }
  
  return "openai"; // Default for backwards compatibility
}

Then use the appropriate endpoint and message format for each provider.

To reproduce

  1. Configure Continue with:
- name: Claude Sonnet 4.5 (Azure)
  provider: azure
  model: claude-sonnet-4-5
  apiBase: https://resource.services.ai.azure.com
  apiKey: <your-api-key>
  env:
    apiType: azure-foundry
  1. Try to chat - generates wrong URL (.../chat/completions instead of .../messages)

  2. Workaround by changing to provider: anthropic - basic chat works

  3. Try to compact conversation - fails with tool_use/tool_result validation error

Log output

HTTP 400 Bad Request from https://resource.services.ai.azure.com/anthropic/v1/messages
{"type":"error","error":{"type":"invalid_request_error","message":"messages.16: `tool_use` ids were found without `tool_result` blocks immediately after: tooluse_XXX"}}

Metadata

Metadata

Labels

area:integrationIntegrations (context providers, model providers, etc.)ide:vscodeRelates specifically to VS Code extensionkind:bugIndicates an unexpected problem or unintended behavioros:windowsHappening specifically on Windows

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions