Repository navigation
fix(glm): accept OpenRouter's reasoning.context and reasoning.mode on GLM-5.3-Flash - #1585
Closed
jonathan308 wants to merge 2 commits into
Closed
jonathan308 wants to merge 2 commits into
jonathan308 wants to merge 2 commits into
Conversation
… GLM-5.3-Flash OpenRouter's reasoning-content-return readiness test now returns the model's reasoning on a get_time tool call and asks for a secret word chosen in that reasoning. A 123-variant matrix of that request family, run through the coordinator-path handling (decodeInboundChatRequest, validateNativeControls, the scheduler and the shipped template), shows 0.10.1 serves every reasoning carrier, reasoning_details field, strict or empty-schema declaration, argument spelling and reasoning control the test can send, and renders the returned reasoning. 0.10.0 refuses strict tools, empty-string arguments and null reasoning members with 400 invalid_request, and drops returned reasoning. The documented OpenRouter fields 0.10.1 still refused were the reasoning object's context and mode members, rejected as unknown members: - reasoning.context spells the template's clear_thinking: current_turn keeps only the reasoning returned after the last user turn (true), all_turns every turn's (false), and auto or null is unset. Other values, and a context that contradicts the effective clear_thinking, stay refused, never reconciled. - reasoning.mode standard, OpenRouter's default, is a no-op. pro names a model variant GLM does not have and stays refused. Tests: every golden renders byte for byte with its clear_thinking replaced by the equivalent context; current_turn renders like clear_thinking true with and without a later user turn; contradictions are refused on the coordinator and local paths; the secret-word turn is served through the scheduler with each reasoning carrier, the strict declaration, empty-string arguments and the new controls. Each new test fails on master's policy. Docs and a changelog fragment are updated.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…e place The first version expressed the reasoning.context rule twice: validate() refused a context that contradicts the raw clear_thinking, and additionalContext() repeated the comparison against the typed controls' value and then resolved explicit ?? context ?? false on its own. RawControls.resolvedClearThinking(explicit:) now holds the whole rule: the explicit Boolean, else the one reasoning.context spells, else false, refusing a context that contradicts the explicit Boolean. validate() and additionalContext() both call it, at the same points as before, so the refusal order, message and rendered value are unchanged. The single-use contradictoryReasoningContext constant is inlined. Behavior-preserving: the GLM prompt-policy and OpenRouter capability suites (42 tests, every golden render included) and the broader GLM/prompt/request selection pass unchanged.
This was referenced Oct 24, 2026
Collaborator
Author
|
Superseded by #1592; consolidated per owner request |
6 of 10 tasks
jonathan308
added a commit
that referenced
this pull request
Oct 25, 2026
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog entry from the 27 fragments added since v0.10.1, ordered by theme behind an upgrade and rollout section: Nemotron 3.5 Super prefix caching (#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590); 4-bit SSD checkpoints and the SSD prefix cache on every model (#1592 (mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and GLM-5.3-Flash (#1564); OpenRouter compatibility: GLM-5.3-Flash and MiMo-V2.6-Flash requests no longer refused (#1585, #1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-lm#362), #1594); Provider diagnostics: refusal reasons and load memory (#1592, #1603); MLX stack (#1596); Desktop release workflow (#1580). Apply 12 corrections reviewed against the code. #1580 is already in the v0.10.1 tag but merged after the 0.10.1 preparation, so its fragment is rendered here. Mark v0.10.1 as published on 2026-10-24. Record in the provider release runbook the SDK pin check, the enablement order (darkbloom-platform#464 before any catalog logprobs change, the GLM allowlist tuple, then both models' logprobs after the rollout and Super's tuple after a signed restart check), the platform evidence and the published history. No tag, registration, upload, deployment or enablement is performed.
jonathan308
added a commit
that referenced
this pull request
Oct 25, 2026
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog entry from the 27 fragments added since v0.10.1, ordered by theme behind an upgrade and rollout section: Nemotron 3.5 Super prefix caching (#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590); 4-bit SSD checkpoints and the SSD prefix cache on every model (#1592 (mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and GLM-5.3-Flash (#1564); OpenRouter compatibility: GLM-5.3-Flash and MiMo-V2.6-Flash requests no longer refused (#1585, #1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-lm#362), #1594); Provider diagnostics: refusal reasons and load memory (#1592, #1603); MLX stack (#1596); Desktop release workflow (#1580). Apply 14 corrections reviewed against the code. #1580 is already in the v0.10.1 tag but merged after the 0.10.1 preparation, so its fragment is rendered here. Mark v0.10.1 as published on 2026-10-24. Record in the provider release runbook the SDK pin check, the enablement order (darkbloom-platform#464 before any catalog logprobs change, the GLM allowlist tuple, then both models' logprobs after the rollout and Super's tuple after a signed restart check), the platform evidence and the published history. No tag, registration, upload, deployment or enablement is performed.
Gajesh2007
pushed a commit
that referenced
this pull request
Oct 25, 2026
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog entry from the 20 fragments added since v0.10.1, ordered by theme behind an upgrade and rollout section: Nemotron 3.5 Super prefix caching (#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590); 4-bit SSD checkpoints and the SSD prefix cache on every model (#1592 (mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and GLM-5.3-Flash (#1564); GLM-5.3-Flash OpenRouter request controls (#1585, #1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx- swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift- lm#362), #1594); Provider diagnostics (#1592); MLX stack (#1596); Desktop release workflow (#1580). Apply 12 corrections reviewed against the code. #1580 is already in the v0.10.1 tag but merged after the 0.10.1 preparation, so its fragment is rendered here. Mark v0.10.1 as published on 2026-10-24. Record in the provider release runbook the SDK pin check, the enablement order (darkbloom-platform#464 before any catalog logprobs change, the GLM allowlist tuple, then both models' logprobs after the rollout and Super's tuple after a signed restart check), the platform evidence and the published history. No tag, registration, upload, deployment or enablement is performed. Co-authored-by: Jonathan Spangler <5055076+jonathan308@users.noreply.github.com>
This branch was successfully deployed
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
OpenRouter's
reasoning-content-returncapability test failed onglm-5.3-flashwith HTTP 400invalid inference request, the coordinator's relay of a providerinvalid_requestrefusal (provider requestnf8vpkl352v2). The test's new prompt returns the model's earlier reasoning on aget_timetool call and asks for a secret word chosen in that reasoning.Verdict on 0.10.1. A 123-variant matrix of this request family, run through the provider's real coordinator-path handling, shows 0.10.1 accepts every variant the test can reasonably send and renders the returned reasoning. That covers each reasoning carrier, every
reasoning_detailsfield and type, the strict and empty-schemaget_timedeclarations,""/"{}"arguments, null/empty/absent assistant content, streaming and non-streaming, and thereasoningcontrolsenabled,effort,max_tokens,exclude:falseandinclude_reasoning:true. 0.10.0 refuses strict tools, empty-string arguments and nullreasoningmembers with exactly this 400. It also drops returned reasoning, so even when it accepts the request the model cannot repeat the returned word. The observed failure therefore points to a provider still on 0.10.0. The remedy for that is the fleet on 0.10.1 plus an OpenRouter retry. On this M3 Ultra the real GLM-5.3-Flash checkpoint passes the secret-word check: OpenRouter-authored reasoning returned asreasoning,reasoning_detailsor both getsSECRET: zephyr, and its own returned turn-1 reasoning gets back its own word.What this PR fixes. The matrix found one remaining gap in 0.10.1: two documented OpenRouter
reasoningmembers were refused as "unknown members".reasoning.contextcontrols which echoed reasoning the model sees;reasoning.modeselects the standard or pro variant. GLM can honor both exactly:Before
flowchart LR classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d classDef step fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b OR["OpenRouter request<br/>reasoning: {context | mode}"]:::step --> CO["coordinator relay"]:::step CO --> DEC["decodeInboundChatRequest<br/>ChatTemplateControls(from:)"]:::step DEC --> CAP{"RawControls.capture"}:::step CAP -- "context / mode = unknown member" --> INV["invalid = true"]:::bad INV --> VAL["validateNativeControls<br/>→ rejectInvalidRequest()"]:::bad VAL --> R400["400 invalid_request<br/>(nothing rendered)"]:::badAfter
flowchart LR classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b classDef bad fill:#fee2e2,stroke:#dc2626,color:#7f1d1d classDef step fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b OR["OpenRouter request<br/>reasoning: {context | mode}"]:::step --> DEC["decodeInboundChatRequest<br/>ChatTemplateControls(from:)"]:::step DEC --> CAP{"RawControls.capture"}:::step CAP -- "context: current_turn" --> CT["contextClearThinking = true"]:::ok CAP -- "context: all_turns" --> AT["contextClearThinking = false"]:::ok CAP -- "context: auto / null<br/>mode: standard" --> NO["no change"]:::ok CAP -- "mode: pro · unknown context" --> INV["invalid"]:::bad CT & AT & NO --> VAL{"validate()"}:::step VAL -- "context ≠ clear_thinking" --> R400["400 invalid_request"]:::bad INV --> R400 VAL -- "consistent" --> CTX["additionalContext<br/>clear_thinking = explicit ?? context ?? false"]:::ok CTX --> R200["template renders the returned<br/>reasoning → 200"]:::okLegend: green = served, red = refused with 400
invalid_request, blue = unchanged step.Evidence
Method. Each variant body is serialized as the coordinator re-marshals it, with sorted keys. It then follows
ProviderLoop+InferenceHandlerexactly:decodeInboundChatRequest, thenvalidateNativeControls(glm5_next)(both refusals map torejectInvalidRequest(), a 400invalid_request), then the forced stream withinclude_usageand the inferred reasoning parser, thenMultiModelBatchSchedulerEngineover a GLM slot, thenMLXOpenAIService.streamChatCompletionFrames. The GLM slot uses the shipped template, the servingGLM5NextThinkingTokenizerand a scripted CBv2 engine. "Seen" means the assistant turn renders<think>{returned reasoning}</think><tool_call>get_time…. The same harness ran onv0.10.0(1ef9c89f),v0.10.1(9034a5a0) and this branch.Refused. 0.10.0: 32 of 123. 0.10.1: 19. This branch: 14.
Refused before, accepted after (this PR):
reasoning: {context: "all_turns"}reasoning: {enabled: true, context: "auto"}reasoning: {mode: "standard"}reasoning: {effort: "high", context: "current_turn"}reasoning: {context: "all_turns"}+clear_thinking: falseStill refused with a typed 400, by design or by the OpenAI spec:
reasoning.mode: "pro"contextvaluecontextcontradictingclear_thinkingreasoning.exclude: trueandinclude_reasoning: falsepreserve_thinkingreasoningmembersreasoning_effort: nullandenable_thinking: null(not OpenRouter-nullable under the existing rule)reasoning.max_tokens: 0arguments: "null"argumentstypeAccepted by 0.10.1, refused by 0.10.0 (the straggler):
stricttools (every strict variant, and the first turn too),arguments: "",reasoning: null, nullreasoningmembers andreasoning.summary. On 0.10.0 returnedreasoning/reasoning_detailsis never seen.Full matrix (123 variants)
reasoning: null/ null members not unset (v0.10.0 GLM5NextPromptPolicy.swift:145-150)reasoning: null/ null members not unset (v0.10.0 GLM5NextPromptPolicy.swift:145-150)reasoningmember (v0.10.0 GLM5NextPromptPolicy.swift:146-149)reasoning_effortis not nullable:effort(root, "reasoning_effort")(GLM5NextPromptPolicy.swift:172) throws, capture marksinvalid,validate()refuses (GLM5NextPromptPolicy.swift:245-248)reasoningmembercontext(GLM5NextPromptPolicy.swift:199-209) ->validate()(GLM5NextPromptPolicy.swift:245-248)reasoningmembercontext(GLM5NextPromptPolicy.swift:199-209)reasoningmembermode(GLM5NextPromptPolicy.swift:199-209)reasoning budget must be positive(GLM5NextPromptPolicy.swift:213-217)enable_thinkingis Boolean only:thinkingSwitch(root, "enable_thinking")(GLM5NextPromptPolicy.swift:170)reasoningmembercontext(GLM5NextPromptPolicy.swift:199-209)reasoningmember (v0.10.0 GLM5NextPromptPolicy.swift:146-149)reasoningmembercontext(GLM5NextPromptPolicy.swift:199-209)reasoningmembermode(GLM5NextPromptPolicy.swift:199-209); fix:prois not innoOpReasoningMembers["mode"](GLM has no pro variant)reasoningmembercontext(GLM5NextPromptPolicy.swift:199-209); fix:unsupported reasoning contextreasoningmembercontext(GLM5NextPromptPolicy.swift:199-209); fix:reasoning.context cannot contradict clear_thinking(validate())reasoningExclusionUnsupported(GLM5NextPromptPolicy.swift:249-251)reasoningExclusionUnsupported(GLM5NextPromptPolicy.swift:249-251)preserve_thinkingrefused (GLM5NextPromptPolicy.swift:169)reasoningmember (GLM5NextPromptPolicy.swift:199-209)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)decodeHistoryArguments(GLM5NextPromptPolicy.swift:476-478)OpenAIToolCall.Function.arguments: String(OpenAIProtocol.swift:339) failsdecodeInboundChatRequest->rejectInvalidRequest()(ProviderLoop+InferenceHandler.swift:351-363)OpenAIToolCall.type: String(OpenAIProtocol.swift:348) failsdecodeInboundChatRequest->rejectInvalidRequest()(ProviderLoop+InferenceHandler.swift:351-363)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)strict tool decoding is not qualified(v0.10.0 GLM5NextPromptPolicy.swift:266-268)Tests. Each new test, and each new case in an extended test, fails on master's policy and passes with the fix:
GLM5NextPromptPolicyTests/reasoningContextRendersEveryGoldenLikeItsClearThinkingSpellingreplaces each official golden'sclear_thinkingspellings with the equivalentreasoning.context. All seven goldens must still match byte for byte, includingclear-historical-reasoningandclear-keeps-current-turn-reasoning.currentTurnReasoningContextRendersLikeClearThinking:current_turnrenders exactly likeclear_thinking: true, with and without a later user turn.reasoningContextContradictingClearThinkingIsRefused: refused on the coordinator and local paths.GLM5NextOpenRouterCapabilityTests/openRouterSecretWordReasoningReturnIsServedruns the secret-word turn through the scheduler and service. It coversreasoning, Darkbloom-shapedreasoning_detailsand both carriers; strict plus""arguments; andeffort/max_tokens/include_reasoning/tool_choice/parallel_tool_calls/context/mode.Real GLM-5.3-Flash checkpoint: PASS.
Setup.
m5max-proof/lane_run.sh); 239 GB reclaimable, no Super or provider runner.3aae613f…, re-verified by the managed load (134.5 s).GLM5NextRealModelHarness.chat, the production decode, policy, scheduler, real bridge with MTP andMLXOpenAIService. Scratch test, not in this PR.Turn 1. Strict
get_time; the model chose "penguin" while reasoning and calledget_timewith"{}".Results.
reasoningSECRET: zephyrreasoning_detailsentrySECRET: zephyrreasoning: {enabled: true, context: "all_turns"}(needs this PR)SECRET: zephyrreasoning+arguments: ""+{context: "current_turn", mode: "standard"}(needs this PR)SECRET: zephyrSECRET: penguinSECRET: banana(cannot see it)Tiny synthetic GLM loaded by
ProviderLoop.ensureModelLoaded: PASS.DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY=1,DARKBLOOM_CBV2_MTP=1, under the GPU lane.reasoning,reasoning_details, both with strict and""arguments, encrypted and text details withparameters: {}, a budget withstream: false, and the control.validateNativeControls:context: all_turnsandcontext: current_turn+mode: standard.mode: pro,exclude: trueand a context contradictingclear_thinkingstay 400.Limitations.
coordinator/promptsidecar/src/glm5_next.rs,reasoning_members) still refusescontextandmode. Such requests get no coordinator cache plan: the planner falls back to heuristics and the request is not refused. Mirroring this needs a coordinated platform change.docs/architecture/inference.mdanddocs/developer/test.mdare also touched by Logprobs follow-up: GLM-5.3-Flash and Nemotron 3.5 Super #1564 (different paragraphs).Refactor pass: one behavior-preserving change, signed commit
cca4aa11f.Change. The first version stated the
reasoning.contextrule twice:validate()refused a context that contradicts the rawclear_thinking;additionalContext()repeated that comparison against the typed controls' value, then resolvedexplicit ?? context ?? falseseparately.RawControls.resolvedClearThinking(explicit:)now holds the whole rule, and both call it at the same points as before. The refusal order, the message (reasoning.context cannot contradict clear_thinking) and the rendered value are unchanged. The single-usecontradictoryReasoningContextconstant is inlined (1 file, +12/−10).Reviewed, no change needed: the
context/modecapture (noOpReasoningMembersand the context switch), the tests, the docs and the changelog fragment.Validation on
cca4aa11f. Fresh worktree, debug build with tests, source-matched metallib staged, and isolatedDARKBLOOM_STATE_FILE/DARKBLOOM_LOADED_MODELS_FILE/DARKBLOOM_VERIFIED_WEIGHTS_FILE:Sidecar parity follow-up: Layr-Labs/darkbloom-platform#461 (draft) mirrors these semantics in the prompt sidecar.
protocol-messages.mdsentence saying the sidecar still refusesreasoning.contextandreasoning.modebecomes stale.Merge Danger
Door: two-way
Only requests that were refused are newly accepted. Every previously accepted request renders identically: the golden no-op checks pass unchanged.
Blast Radius: GLM-only
The change is limited to
GLM5NextPromptPolicyrequest-control validation forglm5_nextslots. No protocol, catalog, coordinator or release change.