Skip to content

Provider API: /v1/responses drops type:"custom" tools and rejects custom_tool_call/custom_tool_call_output input (deepseek-v4.1-flash) #1185

Todo

Description

@Zoranner

Summary

POST https://api.commandcode.ai/provider/v1/responses has two related compatibility failures with deepseek/deepseek-v4.1-flash:

  1. type: "custom" tool declarations are dropped by some requests/backends. A request containing only the freeform apply_patch custom tool and tool_choice: "required" returns HTTP 400: tool_choice requires tools when it is required or names a function. The gateway behaves as if tools were empty.
  2. Replaying standard custom_tool_call / custom_tool_call_output items in input returns HTTP 400 unsupported_input_item. The request has no item_reference, previous_response_id, or conversation, and uses store: false.

This breaks Codex's freeform apply_patch loop. A session can complete several custom tool calls and then fail on the next ordinary follow-up when the client replays the custom call/output history.

Impact

Prelay is a multi-tenant gateway. Our service records show 171 occurrences of the unsupported_input_item 400 across 4 distinct device identities, all on Command Code + deepseek/deepseek-v4.1-flash + /provider/v1/responses. First seen 2026-11-03; 118 of the 171 occurred on 2026-11-28 alone.

In one Codex/Paseo session, 16 custom apply_patch calls succeeded. The next ordinary follow-up failed with the 400 above, and the session could not continue.

To keep serving, Prelay currently normalizes type:"custom" tools and custom_tool_call items to function form for this upstream. That loses the freeform apply_patch contract and cannot resume existing sessions. Native support on /responses is the only non-lossy fix.

Minimal reproduction A: custom tool is dropped before tool_choice validation

The request below is direct to the endpoint and uses no Prelay-specific fields or headers. ping is a synthetic placeholder, not user content.

POST https://api.commandcode.ai/provider/v1/responses
Authorization: Bearer $CMD_API_KEY
Content-Type: application/json

{
  "model": "deepseek/deepseek-v4.1-flash",
  "input": "ping",
  "tools": [
    {
      "type": "custom",
      "name": "apply_patch",
      "description": "Apply a patch to files.",
      "format": { "type": "text" }
    }
  ],
  "tool_choice": "required",
  "store": false,
  "stream": false
}

Actual: HTTP 400, error message:

tool_choice requires tools when it is required or names a function.

The request contains exactly one tool. The error says there are no tools. This is consistent with the custom declaration being removed before tool_choice validation.

Expected: HTTP 200; with tool_choice: "required" we expect a custom_tool_call to apply_patch. If type:"custom" is intentionally unsupported, return a specific error that names the unsupported type, not “no tools”.

Minimal reproduction B: replayed custom items are rejected

Step 1: capture a custom_tool_call from a successful custom-tool turn:

{
  "type": "custom_tool_call",
  "call_id": "call_<redacted>",
  "name": "apply_patch",
  "input": "*** Begin Patch\n*** End Patch"
}

Step 2: send the next turn with the call and its output in input:

POST https://api.commandcode.ai/provider/v1/responses
Authorization: Bearer $CMD_API_KEY
Content-Type: application/json

{
  "model": "deepseek/deepseek-v4.1-flash",
  "store": false,
  "stream": false,
  "tools": [
    {
      "type": "custom",
      "name": "apply_patch",
      "description": "Apply a patch to files.",
      "format": { "type": "text" }
    }
  ],
  "input": [
    { "role": "user", "content": "continue" },
    {
      "type": "custom_tool_call",
      "call_id": "call_<redacted>",
      "name": "apply_patch",
      "input": "*** Begin Patch\n*** End Patch"
    },
    {
      "type": "custom_tool_call_output",
      "call_id": "call_<redacted>",
      "output": "done"
    }
  ]
}

No tool_choice is set, so this is not the tool_choice error from A. There is no item_reference, previous_response_id, or conversation; store is false. continue and done are synthetic placeholders, not user content.

Actual: HTTP 400

{
  "error": {
    "message": "input items may be messages, function calls, function call outputs and reasoning. Item references need stored responses, which are not kept.",
    "type": "invalid_request_error",
    "code": "unsupported_input_item",
    "param": "input"
  }
}

Expected: HTTP 200. custom_tool_call and custom_tool_call_output are standard OpenAI Responses input items for client-executed custom tools. They are inline items, not item_reference, and do not require stored responses. The endpoint should accept them with store:false.

Expected behavior

  1. Preserve type:"custom" tools in tools. Both tool_choice:"required" and tool_choice:{"type":"custom","name":"apply_patch"} must see them.
  2. Accept custom_tool_call and custom_tool_call_output as inline input items, independent of store and without previous_response_id/conversation.
  3. If an item type is intentionally unsupported, name the item type and the supported set in the error; do not describe a real custom item as an item_reference that needs stored responses.
  4. Add regression tests for A and B.

Why this is a Provider API bug

The Provider API docs say:

Tool arrays pass through as you send them. function and custom tools are executed by your client, and built-in declarations such as web_search are forwarded for the upstream to accept or refuse, so an agent client that sends a mixed array works unchanged.

The launch post says:

Function and custom tools stay client-side.

The same docs say /responses follows the OpenAI Responses schema. In that schema, custom_tool_call and custom_tool_call_output are valid input items; the OpenAI SDK includes both in the ResponseInputItem union. The requests above use only documented fields and no stored-response features.

Both errors are gateway-side request-validation errors returned before model output; they are not model refusals. This also looks like a regression or partial fix of #885 (closed 2026-09-18). #885 fixed the endpoint rejecting non-function tool declarations. If the fix was to accept and ignore non-function declarations, that is not sufficient for type:"custom": custom tools are client-executed and must be preserved; only built-in declarations may be forwarded/ignored.

The official Tool Call Repairs page describes CLI-side tool-input repair; it does not document Provider API item validation or custom tool preservation, so it does not cover this gap.

Environment

  • Endpoint: https://api.commandcode.ai/provider/v1/responses
  • Model: deepseek/deepseek-v4.1-flash
  • Route: /responses (the model is served on this route; this is not a /messages mismatch)
  • Client: Codex CLI / Paseo harness over the Responses wire, behind the Prelay gateway
  • Command Code CLI version: N/A (Provider API only)
  • OS: N/A (server-side API)
  • First seen: 2026-11-03
  • Last seen: 2026-11-28
  • Volume: 171 unsupported_input_item 400s across 4 device identities; 118 on 2026-11-28
  • Timezone: Asia/Shanghai (UTC+8)

Related issues

  • #885 — /v1/responses rejects Codex's non-function tool types (closed/fixed 2026-09-18). This report is the next layer: custom declarations are accepted/dropped, and custom input items are rejected.
  • #949 — deepseek/deepseek-v4.1-flash reasoning content:null on /responses (open). Same model/endpoint, different item.
  • #965 / #970 — intermittent opaque 400s on /responses with the same model (open). Different signature; not duplicates.
  • #1163 — opaque 400 on long tool-heavy sessions (open). Different signature.

I did not find an existing issue for custom_tool_call / unsupported_input_item. If this is a duplicate, please link it and I will add the repro there.

What we're asking for

  1. Confirm whether type:"custom" tools are supposed to be preserved on /responses for this model. The docs say yes; the behavior says no.
  2. Confirm whether custom_tool_call / custom_tool_call_output are supported input items. If not, document the supported item set and return a specific error; if yes, fix the validator.
  3. If this is a backend/gray-release issue, confirm which backend/version is serving this model and the rollback/fix ETA.
  4. If the fix is gated, suggest a workaround that preserves freeform apply_patch semantics, not a lossy function rewrite.

Privacy

The payloads above are minimal and synthetic. They contain no API key, no real user prompt, and no user content beyond the tool name, item types, and status/error text. I can provide exact timestamps and sanitized request IDs privately; I will not attach full request bodies or session files.

Could a maintainer add the Provider label for triage? Thank you.

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