Skip to content

Provider API: opaque 400 "Request validation failed." (no param) on long tool-heavy sessions, DeepSeek lane #1163

Open

Description

@bobobo2026

Summary

On the Provider API (POST /provider/v1/chat/completions), a long, tool-heavy session gets a deterministic 400 with an opaque message and no param:

{"error":{"message":"{\"error\":{\"message\":\"Request validation failed.\",\"type\":\"invalid_request_error\",\"code\":\"400\"}}","type":"invalid_request_error"}}

Note the message is a JSON string nested inside the message field — so the client sees an error whose text is another JSON document, with "code":"400" (not the usual param-bearing body). There is nothing for the caller to act on: no field path, no trace id, no documented limit to compare against.

Impact

A single session becomes permanently unusable: the client rebuilds the same history on every retry, so every subsequent turn fails the same way. Users have to abandon the conversation and start a new one.

Evidence

Captured the exact request body that fails (tcpdump on the loopback hop of our gateway, body reassembled and replayed):

  • model: deepseek/deepseek-v4.1-flash
  • body: 3.7–3.9 MB
  • messages: ~220 (1 system / 52–59 user / 124–196 assistant / 119–191 tool)
  • tools: 39 function tools, no duplicate names
  • max_tokens: 128000, stream: true, stream_options.include_usage: true
  • 8–9 image_url parts (real PNG/JPEG data URLs, in user messages)
  • every assistant message carries reasoning_content

The same body is accepted by the DeepSeek official API (200), and by another account in the same pool, so the payload itself is well-formed. Only the Command Code lane rejects it — and only for sessions of this size; smaller requests with the same tools/model return 200.

What we already ruled out (all return 200 on CC)

  • duplicate function.name in tools (CC rejects this, but with a different error)
  • tool_choice pointing at an unknown tool (also a different error)
  • max_tokens 8k → 128k
  • single message bodies up to 5 MB, and up to ~400k tokens of real text
  • images up to 7.6 MB as data URLs, including inside tool messages
  • reasoning_content on user / assistant / tool / system messages, and as array (array is rejected with a param, string is fine)
  • null-valued fields: parallel_tool_calls, tool_choice, max_tokens, temperature, top_p — these all produce a useful param error, which is what we'd expect here too

Ask

  1. Is there a documented limit on request body size / token count / message count for /chat/completions? If yes, which one, and can the error become explicit (param or code) instead of Request validation failed.?
  2. If the nested "code":"400" string is coming from an upstream lane rather than your validator, can that be surfaced distinctly?
  3. Any chance of a trace/request id in the 400 body? We can supply full request bodies (privacy-scrubbed) plus timestamps if it helps.

Related issues

Both point at the same shape: one field in a large request kills the entire call, and the failure is hard to attribute.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions