continue icon indicating copy to clipboard operation
continue copied to clipboard

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

Open woter1832 opened this issue 11 months ago • 2 comments

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

woter1832 avatar Dec 30 '25 04:12 woter1832

Related Issues

Based on my search, here are related issues:

Duplicate/Highly Related:

  • #9224 - Error: "Requested API is currently not supported" when using Azure Foundry deployed Anthropic models

Related (Azure AI Foundry context):

  • #3902 - Cannot setup Deepseek model using Azure Foundry
  • #3938 - Cannot Provision DeepSeek R1 from Azure Foundry

Related (Conversation compacting/token counting):

  • #9231 - Context length calculation incorrect for Anthropic Claude models (shows 130k tokens at 70% when actually 200k)
  • #8187 - Continue ignores contextLength when using openai provider with local server

Related (Azure endpoint issues):

  • #9133 - 🐛 Azure OpenAI /responses endpoint not supported for GPT-5 Codex models
  • #3424 - Azure OAI in v0.8.63-vscode got Error: Error parsing response body

Related (Tool use issues):

  • #4493 - Anthropic tool support via Vertex AI (different provider with similar tool use challenges)

continue avatar Dec 30 '25 04:12 continue

Closing as a duplicate of #9224.

The solution is to use provider: anthropic (not provider: azure) with Azure AI Foundry. The azure provider is only for Azure OpenAI Service (GPT models).

The tool_use compaction error I mentioned is a separate Continue bug unrelated to Azure - I'll create a new issue for that if it persists.

See updated documentation: [link to PR]

woter1832 avatar Jan 09 '26 10:01 woter1832