Skip to content

fix(claude): resolve web_search tool_choice and invalid reasoning summary when routing Claude Desktop to OpenAI models #1426

Description

@tqctqc1

Client or integration

Other

Provider or upstream service

OpenAI (Codex login / Responses API)

OpenCodex version

2.7.38

Endpoint or capability

/v1/responses (Claude Desktop Messages -> Responses translation)

Current behaviour

When routing Claude Desktop requests to OpenAI upstream models (gpt-5.6-luna, gpt-5.4-mini):

  1. Turns with disabled thinking (thinking: { type: "disabled" }) set reasoning: { effort: "none", summary: "none" }. OpenAI rejects summary: "none" with HTTP 400 invalid_request_error: Invalid value: 'none'. Supported values are: 'concise', 'detailed', and 'auto'.
  2. Enforced web_search tool choice (tool_choice: { type: "tool", name: "web_search" }) sets tool_choice: { type: "function", name: "web_search" } while tools array contains { type: "web_search" }. OpenAI rejects with HTTP 400 invalid_request_error: Tool choice 'function' not found in 'tools' parameter.

Expected behaviour

  1. Explicitly disabled thinking in inbound.ts should set reasoning: { effort: "none" } without emitting invalid summary: "none".
  2. Hosted web_search tool choice should map to { type: "web_search" } instead of { type: "function", name: "web_search" }.
  3. Unmatched function tool choices should be sanitized or downgraded to "auto" in openai-responses.ts before upstream dispatch.

Minimal redacted request or reproduction

// Inbound Anthropic request from Claude Desktop on WebSearch:
{
  "model": "gpt-5.6-luna",
  "thinking": { "type": "disabled" },
  "tools": [{ "name": "web_search", "type": "web_search" }],
  "tool_choice": { "type": "tool", "name": "web_search" }
}

Actual response or error

HTTP 400 Bad Request
{
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid value: 'none'. Supported values are: 'concise', 'detailed', and 'auto'."
  }
}
// and subsequently:
{
  "error": {
    "type": "invalid_request_error",
    "message": "Tool choice 'function' not found in 'tools' parameter."
  }
}

Upstream documentation

https://docs.anthropic.com/en/api/messages

Suggested mapping or implementation notes

In src/claude/inbound.ts:

  1. Remove summary: "none" from body.reasoning when thinkingDisabled is true.
  2. Use isClaudeWebSearchToolName(choice.name) in toolChoiceToResponses to map tool_choice to { type: "web_search" } when target is a hosted web_search tool.

In src/responses/schema.ts:

  1. Add "web_search" to hostedToolType enum.

In src/adapters/openai-responses.ts:

  1. Add stripInvalidReasoningSummary to strip invalid summary values (like "none").
  2. Add sanitizeUnmatchedToolChoice to sanitize function tool choices that don't match any function declared in tools.

Additional context and attachments

Verified fix locally on Windows with Claude Desktop 3P mode.

Checks

  • I searched existing provider and compatibility issues.
  • The request and response were redacted.
  • The expected behaviour is based on an upstream specification or a concrete client requirement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    providerProvider adapters, OpenAI-compat presets, upstream API quirksprovider-compatibilityProvider compatibility reports

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions