fix(executors): strip client context_management on 400 (port from 9router#1468)

Claude Code always sends a top-level `context_management` field. Strict
anthropic-compatible gateways reject it with 400 "context_management: Extra
inputs are not permitted". The dedicated context-editing 400-fallback in
base.ts only fires when OmniRoute's own `contextEditing` feature is enabled
(default off), so a client-sent field passed through untouched and 400'd with
no recovery. Add `context_management` to KNOWN_OFFENDING_FIELDS so the generic
reactive 400 field-downgrade strips-and-retries it once, independent of the
feature flag (the generic path already re-signs for claude-compatible relays).

Regression guard: tests/unit/provider-field-strips.test.ts.

Reported-by: ohahe52-dot (https://github.com/decolua/9router/issues/1468)
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-06 16:53:43 -03:00
parent fb3da7ce98
commit b6f2bd85fe
3 changed files with 14 additions and 0 deletions

View File

@@ -9,6 +9,12 @@ test("findOffendingField matches known field names in a 400 body", () => {
assert.equal(findOffendingField("Invalid argument: reasoning_budget not supported"), "reasoning_budget");
assert.equal(findOffendingField("unexpected field chat_template"), "chat_template");
assert.equal(findOffendingField("reasoning_content is not allowed"), "reasoning_content");
// #1468: Claude Code's top-level context_management field rejected by strict
// anthropic-compatible gateways → strip + retry regardless of the contextEditing flag.
assert.equal(
findOffendingField("context_management: Extra inputs are not permitted"),
"context_management"
);
assert.equal(findOffendingField("all good"), null);
assert.equal(findOffendingField(""), null);
});