Skip to content

Claude Code optional tool parameters become strict on OpenAI Responses routes #3922

Description

@barbusina

Client or integration

Claude Code

Provider or upstream service

OpenAI Responses API / ChatGPT Codex

OpenCodex version

2.47.0 / commit 8bc9e4e

Endpoint or capability

/v1/messages → /v1/responses function tool translation

Current behaviour

When Claude Code sends a custom tool definition without an explicit strict field, OpenCodex translates it into a Responses function tool while also omitting strict.

This changes the request semantics because the Responses API treats an omitted strict value as strict mode. As a result, parameters that are optional in the original Anthropic input_schema can be treated as required by the upstream Responses provider.

For example, a tool may require only prompt while defining isolation and options as optional. After translation, the upstream provider applies strict schema handling even though the client did not request it.

Expected behaviour

Translated function tools should preserve the semantics of the original Anthropic tool definition:

  • If strict is omitted, OpenCodex should emit strict: false.
  • An explicit strict: false should remain false.
  • An explicit strict: true should remain true.
  • The supplied JSON Schema should be forwarded without rewriting its
    properties, required, or nested schemas.
  • Hosted tools such as web search should remain unaffected.
  • Native Anthropic passthrough should remain unaffected.

Minimal redacted request or reproduction

curl http://127.0.0.1:10100/v1/messages \
  -H 'content-type: application/json' \
  -H 'x-api-key: REDACTED' \
  -H 'anthropic-version: 2023-06-01' \
  -d '{
    "model": "openai/gpt-5.4",
    "max_tokens": 32,
    "messages": [
      {
        "role": "user",
        "content": "Run a local agent."
      }
    ],
    "tool_choice": {
      "type": "tool",
      "name": "Agent"
    },
    "tools": [
      {
        "name": "Agent",
        "description": "Run an agent",
        "input_schema": {
          "type": "object",
          "properties": {
            "prompt": {
              "type": "string"
            },
            "isolation": {
              "type": "string",
              "enum": ["worktree", "remote"]
            },
            "options": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                }
              }
            }
          },
          "required": ["prompt"],
          "additionalProperties": false
        }
      }
    ]
  }'

Actual response or error

The forwarded `/v1/responses` function tool omits the `strict` field:

{
  "type": "function",
  "name": "Agent",
  "parameters": {
    "type": "object",
    "properties": {
      "prompt": { "type": "string" },
      "isolation": {
        "type": "string",
        "enum": ["worktree", "remote"]
      },
      "options": {
        "type": "object",
        "properties": {
          "enabled": { "type": "boolean" }
        }
      }
    },
    "required": ["prompt"],
    "additionalProperties": false
  }
}

The Responses upstream consequently applies its default strict semantics, although the originating Anthropic request did not enable strict tool use. This breaks tool calls in which the optional arguments are omitted.

Upstream documentation

Anthropic tool definitions and optional parameters:
https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools

Anthropic strict tool use is enabled explicitly with strict: true:
https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use

OpenAI Responses API reference:
https://platform.openai.com/docs/api-reference/responses/create

Suggested mapping or implementation notes

During Anthropic Messages → Responses translation, emit:
strict: typeof tool.strict === "boolean" ? tool.strict : false

The value must then survive the internal parser and the Responses adapter unchanged. Regression coverage should exercise omitted, false, and true values through the complete outbound request-building path and verify that the original JSON Schema is unchanged.

Additional context and attachments

The fix has been verified against the reported failure. It restores optional tool arguments while preserving explicit strict-mode requests, hosted web search, and native Anthropic passthrough.

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    providerProvider adapters, OpenAI-compat presets, upstream API quirksprovider-compatibilityProvider compatibility reportstoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions