Skip to main content
kRouter
All posts
Fix an error

Four 400s, then success: the beta header that was silently dropped

A captured Claude Code turn was rejected four times before it worked. The body reached Anthropic untouched — the header authorising half its fields did not, and the client degraded itself until something fit.

Kodelyth · The team behind kRouter
7 min read

From one captured Claude Code turn, four rejections in a row:

safeguards: Extra inputs are not permitted
thread: Extra inputs are not permitted
tools.50: Input tag 'advisor_20260301' ... does not match any of the expected tags
thinking.adaptive.display: Input should be 'summarized', 'omitted'

Then a fifth attempt succeeded.

This presents as a flaky network or an overloaded API. It is neither. Every one of those errors is Anthropic correctly rejecting a field that the request was not authorised to send.

What a beta flag actually does

anthropic-beta is not a hint or a preference. It is the thing that authorises the request-body fields that depend on it.

That distinction is the whole bug. The intuition is that dropping a beta flag makes the API ignore the associated feature — degrade gracefully, carry on. It does the opposite: the field becomes unrecognised, and an unrecognised field is a validation error, not something to skip. So dropping one flag does not remove a feature from the response. It rejects the entire request.

Four flags dropped, four different fields unauthorised, four 400s with four different messages — which is why it looks like four unrelated problems rather than one.

The body arrived perfectly

The confusing part is that nothing was wrong with the request body. The router's own log said:

PASSTHROUGH claude -> claude | native lossless

The body reached Anthropic exactly as Claude Code composed it. "Lossless" was true of the thing it was measuring. The header permitting half those fields simply was not sent alongside it.

So you have a request whose payload is byte-for-byte correct, rejected for containing fields it is not allowed to contain — and a log line asserting the request was passed through losslessly, which is true and completely unhelpful.

Two mechanisms that never met

anthropic-beta was already whitelisted into credentials.rawHeaders. The infrastructure to forward the client's own beta flags existed and worked.

Nothing on the Claude path ever read it. The only consumers of rawHeaders were the kiro, opencode, opencode-go and cursor executors. The Claude executor instead assigned selectAnthropicBeta(model, body) from a hardcoded list, unconditionally — overwriting whatever the client had asked for with kRouter's own fixed set.

Two correct mechanisms, built at different times for different reasons, and the one that mattered on this path was never wired to it. Neither is wrong in isolation. kRouter genuinely does need to send its own flags, because the OAuth flag and others are required for its own authentication to work. The client genuinely needs its flags forwarded. Nobody had written down what happens when both are true.

Why some turns worked

Claude Code retries, and on each retry it degrades its own feature set, dropping whatever it guesses caused the rejection.

So it drops safeguards, retries, gets rejected for thread, drops that, retries, and so on — until by the fifth attempt the request shape happens to fit the flags that were actually being sent.

That explains the symptom exactly:

  • turns that eventually worked, at the cost of several rejected upstream calls each
  • turns that failed outright, when the client had nothing left it was willing to degrade
  • an overall impression of intermittency, because the outcome depended on whether a given turn's features happened to be droppable

A well-behaved client's resilience was hiding a deterministic bug behind what looked like flakiness.

The fix

The flags are merged rather than one replacing the other. kRouter's own still ship, because its authentication depends on them. The client's are added, because its request body depends on them.

That is the only resolution that works, and it is worth stating why the two obvious alternatives do not:

  • Send only the client's flags, and kRouter's OAuth authentication breaks.
  • Send only kRouter's, and you are back to rejecting the client's fields — the bug.

Whenever a proxy and its client both have a legitimate claim on the same header, the answer is almost always union, not precedence. Precedence means one side is silently wrong, and the side that loses has no way to find out why.

The general shape

This is the same class as the gzipped bodies and the retirement notice: the request succeeded at the layer that was being measured, and failed at a layer nothing was looking at. The log said lossless. The body was lossless. The authorisation to send that body was not.

It is also the header-shaped version of a problem that shows up in bodies. Three other 400s on well-formed requests came from fields the gateway treated as opaque and the upstream did not. Same lesson from the other direction: a proxy does not get to decide which parts of a request are inert.

If you route Claude Code or Claude Desktop through capture and have seen unexplained 400s or turns that only work on the third try, this landed in 0.5.191.

Kodelyth · The team behind kRouter

Published by Kodelyth, the team that builds kRouter. Posts are drafted with AI assistance and reviewed by a person before they go out. kRouter is free and MIT licensed.

Install kRouter