Repository navigation
fix(responses): repair the Provider API wire for GLM-5.3 and Mistral Large 4 - #215
Merged
Merged
Conversation
…Large 4 Two build-level quirks of the Responses wire, both proven with live requests against https://api.commandcode.ai/provider/v1/responses on 2026-11-13: - zai-org/GLM-5.3 rejects the shorthand `{role, content}` input items the host encoder emits for system and user turns: 400 `input item is missing type`. Adding the item-level `type: "message"` answers 200 with a full SSE stream. A sweep of all 74 models advertising /responses showed GLM-5.3 is the only model refusing the shorthand, so the rewrite is allowlisted. - zai-org/GLM-5.3 and mistral/mistral-large-4 reject `reasoning.effort: "none"`, which pi-ai sends whenever thinking is off: `unsupported output_config.effort: none` and `reasoning_effort none is not supported for this model`. Omitting the field succeeds. Declaring `off: null` in thinkingLevelMap is not a fix: pi clamps to the lowest allowed level and sends `effort: "low"`, silently forcing reasoning on. Both repairs live in a per-model table applied to the /responses fetch wrapper. Every other model keeps the exact bytes the host sends, and malformed or unexpected bodies pass through untouched. Issue: #214
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
Memory benchmarkCompared base
Interpretation: Differences larger than their measured MAD: Physical footprint +0.8 MiB ± 0.8 MiB. Extension overhead above pi baseline
Values are medians of 6 alternating, paired runs. The value after Environment: pi
|
This was referenced Nov 13, 2026
pierreraby
added a commit
that referenced
this pull request
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zai-org/GLM-5.3cannot be used on the/responsesroute at all, in any thinking mode, andmistral/mistral-large-4is broken whenever thinking is off. Both are wire-format mismatches between what the host encoder emits and what the Provider API accepts, and both are fixed here in one per-model repair table.Reported in #214 with a one-message reproduction on 0.8.2 + pi 1.5.2.
What the live API showed
Four request bodies against
zai-org/GLM-5.3onPOST /provider/v1/responses, minimal text-only"hey"withmax_output_tokens: 16:reasoninginvalid_request: input item is missing typetype: "message", noreasoningtype: "message"+reasoning: {effort: "none"}unsupported output_config.effort: nonereasoning: {effort: "none"}input item is missing typeSo there are two stacked causes:
type: "message"for assistant text,function_call,function_call_output,reasoning). The leadingsystem/developeritem and everyuseritem go out as{role, content}. OpenAI accepts it; the adapter in front of GLM-5.3 does not. Verified by driving the installed encoder and dumping the body it builds for this model — the first turn emits one untagged{role: "user", ...}.reasoning.effort: "none". When thinking is off, pi-ai readsthinkingLevelMapand falls back to"none".zai-org/GLM-5.3answersunsupported output_config.effort: none;mistral/mistral-large-4answersreasoning_effort none is not supported for this model, supported values: [high, low, ...]. Both accepteffort: "low"or noreasoningfield at all. Declaringoff: nullis not a fix — pi then clamps to the lowest allowed level and sendseffort: "low", silently forcing reasoning on instead of disabling it.Scope
Sweep of all 74 models advertising
/responses, one minimal text request each:zai-org/GLM-5.3. Every other/responsesmodel accepts the shorthand, so the defaultapi: "openai-responses"routing is not the problem and keeps its cache win.effort: "none"refused by two models:zai-org/GLM-5.3andmistral/mistral-large-4. The Mistral case is unrelated to Bug: invalid request "input item is missing type" on zai-org/GLM-5.3 #214 and simply never got reported.Changes
src/responses-compat.ts—RESPONSES_WIRE_REPAIRS, a per-model table (zai-org/GLM-5.3: both repairs;mistral/mistral-large-4: drop the inert effort), plusrewriteResponsesBody()andwithResponsesWireRepairs(). Returns the original string when nothing changes, and is a no-op for unlisted models, invalid JSON, non-object bodies, and already-tagged items.index.ts— one line, inside theopenai-responsesbranch only.tests/test-responses-compat.ts— 13 hermetic tests: tagged vs untouched items, idempotence, reasoning dropped only when it is exactly{effort: "none"}, real efforts preserved, Mistral input left untagged, unlisted models byte-identical, malformed bodies, injectable table, header handling.package.json,CHANGELOG.md.No runtime, routing-default, workflow, version or dependency changes.
Validation
tsc --noEmitPASS,prettier --checkPASS on the whole repo,git diff --checkclean.tests/test-responses-compat.ts13/13 PASS.npm testwithPI_LOCAL_REQUIRED=1 OMP_COMPAT_REQUIRED=1on real hosts (pi 1.5.2,@oh-my-pi18.18.3, bun 1.4.4): PASS, 11 host suite lines green, 0 failures.Not covered here
Two ids are still advertised by
/provider/v1/modelsbut answer 404 at request time (Qwen/Qwen3.6-Max-Preview,stepfun/Step-3.5-Flash). Unrelated to this fix — I will file that separately rather than widen this PR.