Skip to content

fix(glm): accept OpenRouter's reasoning.context and reasoning.mode on GLM-5.3-Flash - #1585

Closed
jonathan308 wants to merge 2 commits into
masterfrom
fix/glm-openrouter-reasoning-context
Closed

jonathan308 wants to merge 2 commits into
masterfrom
fix/glm-openrouter-reasoning-context

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

OpenRouter's reasoning-content-return capability test failed on glm-5.3-flash with HTTP 400 invalid inference request, the coordinator's relay of a provider invalid_request refusal (provider request nf8vpkl352v2). The test's new prompt returns the model's earlier reasoning on a get_time tool 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_details field and type, the strict and empty-schema get_time declarations, ""/"{}" arguments, null/empty/absent assistant content, streaming and non-streaming, and the reasoning controls enabled, effort, max_tokens, exclude:false and include_reasoning:true. 0.10.0 refuses strict tools, empty-string arguments and null reasoning members 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 as reasoning, reasoning_details or both gets SECRET: 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 reasoning members were refused as "unknown members". reasoning.context controls which echoed reasoning the model sees; reasoning.mode selects the standard or pro variant. GLM can honor both exactly:

 RawControls.capture (GLM5NextPromptPolicy.swift)
   reasoning members
-    effort | enabled | exclude | max_tokens | summary* | generate_summary*   else invalid
+    effort | enabled | exclude | max_tokens | summary* | generate_summary*
+    context: current_turn -> clear_thinking true    (the template keeps reasoning after the last user turn only)
+             all_turns    -> clear_thinking false   (every turn's; already the default)
+             auto | null  -> unset
+             other        -> invalid
+    mode:    standard     -> no-op                  (pro: GLM has no pro variant -> invalid)
 validate()
+  context disagrees with the effective clear_thinking -> 400, never reconciled
 additionalContext()
-  clear_thinking = controls ?? raw ?? false
+  clear_thinking = controls ?? raw ?? context ?? false

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)"]:::bad
Loading

After

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"]:::ok
Loading

Legend: 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+InferenceHandler exactly: decodeInboundChatRequest, then validateNativeControls(glm5_next) (both refusals map to rejectInvalidRequest(), a 400 invalid_request), then the forced stream with include_usage and the inferred reasoning parser, then MultiModelBatchSchedulerEngine over a GLM slot, then MLXOpenAIService.streamChatCompletionFrames. The GLM slot uses the shipped template, the serving GLM5NextThinkingTokenizer and a scripted CBv2 engine. "Seen" means the assistant turn renders <think>{returned reasoning}</think><tool_call>get_time…. The same harness ran on v0.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):

    Variant 0.10.1 After
    reasoning: {context: "all_turns"} 400 200, seen
    reasoning: {enabled: true, context: "auto"} 400 200, seen
    reasoning: {mode: "standard"} 400 200, seen
    reasoning: {effort: "high", context: "current_turn"} 400 200, seen (the call is the current turn)
    reasoning: {context: "all_turns"} + clear_thinking: false 400 200, seen
  • Still refused with a typed 400, by design or by the OpenAI spec:

    • reasoning.mode: "pro"
    • an unknown context value
    • context contradicting clear_thinking
    • reasoning.exclude: true and include_reasoning: false
    • preserve_thinking
    • contradictory thinking switches
    • unknown reasoning members
    • reasoning_effort: null and enable_thinking: null (not OpenRouter-nullable under the existing rule)
    • reasoning.max_tokens: 0
    • tool-call arguments: "null"
    • non-string arguments
    • a tool call without type
  • Accepted by 0.10.1, refused by 0.10.0 (the straggler): strict tools (every strict variant, and the first turn too), arguments: "", reasoning: null, null reasoning members and reasoning.summary. On 0.10.0 returned reasoning/reasoning_details is never seen.

Full matrix (123 variants)
ID Variant 0.10.0 0.10.1 fix Why refused (0.10.1 / fix)
A1-reasoning-string assistant.reasoning only (base) 200, not seen 200, seen 200, seen
A2-details-only assistant.reasoning_details [reasoning.text] only 200, not seen 200, seen 200, seen
A3-reasoning-and-details reasoning + reasoning_details 200, not seen 200, seen 200, seen
A4-reasoning-content reasoning_content only (alias) 200, seen 200, seen 200, seen
A5-all-three reasoning_content + reasoning + reasoning_details 200, seen 200, seen 200, seen
A6-none-control no reasoning returned (control: accepted, not visible) 200, not seen 200, not seen 200, not seen
A7-empty-reasoning-plus-details reasoning "" + reasoning_details 200, not seen 200, seen 200, seen
A8-null-reasoning-plus-details reasoning null + reasoning_details 200, not seen 200, seen 200, seen
A9-null-reasoning-content-plus-reasoning reasoning_content null + reasoning 200, not seen 200, seen 200, seen
A10-details-null-plus-reasoning reasoning + reasoning_details null 200, not seen 200, seen 200, seen
A11-details-empty-plus-reasoning reasoning + reasoning_details [] 200, not seen 200, seen 200, seen
A12-darkbloom-streamed-chunks reasoning_details as Darkbloom streamed it: one canonical entry per chunk, same id/index 200, not seen 200, seen 200, seen
B1-darkbloom-canonical text with id reasoning-text-0, format unknown, index 0, signature null 200, not seen 200, seen 200, seen
B2-openai-format-signature text with format openai-responses-v1, id rs_…, signature string 200, not seen 200, seen 200, seen
B3-anthropic-format-signature text with format anthropic-claude-v1, signature sha256:… 200, not seen 200, seen 200, seen
B4-gemini-format text with format google-gemini-v1, index 2 200, not seen 200, seen 200, seen
B5-bare-text text with only type and text 200, not seen 200, seen 200, seen
B6-indexed-split two text entries index 0 and 1 (split thought) 200, not seen 200, seen 200, seen
B7-summary-then-text reasoning.summary then reasoning.text 200, not seen 200, seen 200, seen
B8-encrypted-then-text reasoning.encrypted then reasoning.text 200, not seen 200, seen 200, seen
B9-encrypted-only-plus-reasoning reasoning string + reasoning.encrypted only 200, not seen 200, seen 200, seen
B10-encrypted-only reasoning.encrypted only (accepted; nothing replayable) 200, not seen 200, not seen 200, not seen
B11-summary-only reasoning.summary only (accepted; summary is not replayed) 200, not seen 200, not seen 200, not seen
B12-unknown-detail-type unknown detail type plus text 200, not seen 200, seen 200, seen
B13-text-null reasoning.text with text null plus reasoning string 200, not seen 200, seen 200, seen
C1-enabled-true reasoning {enabled:true} 200, not seen 200, seen 200, seen
C2-effort-high reasoning {effort:high} 200, not seen 200, seen 200, seen
C3-effort-medium reasoning {effort:medium} 200, not seen 200, seen 200, seen
C4-effort-low reasoning {effort:low} 200, not seen 200, seen 200, seen
C5-effort-minimal reasoning {effort:minimal} 200, not seen 200, seen 200, seen
C6-effort-xhigh reasoning {effort:xhigh} 200, not seen 200, seen 200, seen
C7-effort-max reasoning {effort:max} 200, not seen 200, seen 200, seen
C8-max-tokens reasoning {max_tokens:2048} 200, not seen 200, seen 200, seen
C9-max-tokens-large reasoning {max_tokens:32000} 200, not seen 200, seen 200, seen
C10-exclude-false reasoning {exclude:false} 200, not seen 200, seen 200, seen
C11-enabled-effort-exclude reasoning {enabled:true, effort:high, exclude:false} 200, not seen 200, seen 200, seen
C12-enabled-max-tokens reasoning {enabled:true, max_tokens:8000} 200, not seen 200, seen 200, seen
C13-effort-and-max-tokens reasoning {effort:high, max_tokens:2048} 200, not seen 200, seen 200, seen
C14-include-reasoning-true include_reasoning true 200, not seen 200, seen 200, seen
C15-include-reasoning-and-enabled include_reasoning true + reasoning {enabled:true} 200, not seen 200, seen 200, seen
C16-reasoning-effort-top reasoning_effort high (top level) 200, not seen 200, seen 200, seen
C17-reasoning-null reasoning null 400 200, seen 200, seen 0.10.0 only: reasoning: null / null members not unset (v0.10.0 GLM5NextPromptPolicy.swift:145-150)
C18-reasoning-empty-object reasoning {} 200, not seen 200, seen 200, seen
C19-null-members reasoning {enabled:true, effort:null, max_tokens:null, exclude:null} 400 200, seen 200, seen 0.10.0 only: reasoning: null / null members not unset (v0.10.0 GLM5NextPromptPolicy.swift:145-150)
C20-summary-auto reasoning {effort:medium, summary:auto} 400 200, seen 200, seen 0.10.0 only: unknown reasoning member (v0.10.0 GLM5NextPromptPolicy.swift:146-149)
C21-enabled-false reasoning {enabled:false} (thinking off) 200, not seen 200, seen 200, seen
C22-effort-none reasoning {effort:none} (thinking off) 200, not seen 200, seen 200, seen
C23-verbosity verbosity medium (OpenRouter parameter) 200, not seen 200, seen 200, seen
C24-reasoning-effort-null reasoning_effort null 400 400 400 reasoning_effort is not nullable: effort(root, "reasoning_effort") (GLM5NextPromptPolicy.swift:172) throws, capture marks invalid, validate() refuses (GLM5NextPromptPolicy.swift:245-248)
C25-context-all-turns reasoning {context:all_turns} (documented, GPT-5.6+) 400 400 200, seen unknown reasoning member context (GLM5NextPromptPolicy.swift:199-209) -> validate() (GLM5NextPromptPolicy.swift:245-248)
C26-enabled-context-auto reasoning {enabled:true, context:auto} 400 400 200, seen unknown reasoning member context (GLM5NextPromptPolicy.swift:199-209)
C27-mode-standard reasoning {mode:standard} (documented) 400 400 200, seen unknown reasoning member mode (GLM5NextPromptPolicy.swift:199-209)
C28-max-tokens-zero reasoning {max_tokens:0} 400 400 400 reasoning budget must be positive (GLM5NextPromptPolicy.swift:213-217)
C29-enable-thinking-null enable_thinking null 400 400 400 enable_thinking is Boolean only: thinkingSwitch(root, "enable_thinking") (GLM5NextPromptPolicy.swift:170)
C30-context-current-turn reasoning {effort:high, context:current_turn} 400 400 200, seen unknown reasoning member context (GLM5NextPromptPolicy.swift:199-209)
C31-context-null-mode-null reasoning {enabled:true, context:null, mode:null} 400 200, seen 200, seen 0.10.0 only: unknown reasoning member (v0.10.0 GLM5NextPromptPolicy.swift:146-149)
C32-context-all-turns-clear-false reasoning {context:all_turns} + clear_thinking false 400 400 200, seen unknown reasoning member context (GLM5NextPromptPolicy.swift:199-209)
R6-mode-pro reasoning {mode:pro} 400 400 400 unknown reasoning member mode (GLM5NextPromptPolicy.swift:199-209); fix: pro is not in noOpReasoningMembers["mode"] (GLM has no pro variant)
R7-context-unknown reasoning {context:every_turn} 400 400 400 unknown reasoning member context (GLM5NextPromptPolicy.swift:199-209); fix: unsupported reasoning context
R8-context-contradiction reasoning {context:current_turn} + clear_thinking false 400 400 400 unknown reasoning member context (GLM5NextPromptPolicy.swift:199-209); fix: reasoning.context cannot contradict clear_thinking (validate())
R1-exclude-true reasoning {exclude:true} 400 400 400 hidden reasoning: reasoningExclusionUnsupported (GLM5NextPromptPolicy.swift:249-251)
R2-include-reasoning-false include_reasoning false 400 400 400 hidden reasoning: reasoningExclusionUnsupported (GLM5NextPromptPolicy.swift:249-251)
R3-preserve-thinking preserve_thinking true 400 400 400 preserve_thinking refused (GLM5NextPromptPolicy.swift:169)
R4-contradiction reasoning {enabled:true} + reasoning_effort none 400 400 400 contradictory thinking switches (GLM5NextPromptPolicy.swift:253-255)
R5-unknown-member reasoning {effort:high, foo:1} 400 400 400 unknown reasoning member (GLM5NextPromptPolicy.swift:199-209)
D1-tool-choice-auto tool_choice auto 200, not seen 200, seen 200, seen
D2-tool-choice-absent tool_choice absent (base) 200, not seen 200, seen 200, seen
D3-tool-choice-object-auto tool_choice {type:auto} 200, not seen 200, seen 200, seen
D4-tool-choice-none tool_choice none 200, not seen 200, seen 200, seen
D5-parallel-true parallel_tool_calls true 200, not seen 200, seen 200, seen
D6-parallel-false parallel_tool_calls false 200, not seen 200, seen 200, seen
D7-parallel-null parallel_tool_calls null 200, not seen 200, seen 200, seen
D8-strict-true strict true, {type:object, properties:{}} 400 200, seen 200, seen 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
D9-strict-false strict false 200, not seen 200, seen 200, seen
D10-strict-null strict null 200, not seen 200, seen 200, seen
D11-parameters-empty parameters {} 200, not seen 200, seen 200, seen
D12-parameters-empty-strict parameters {} + strict true 400 200, seen 200, seen 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
D13-parameters-object-only parameters {type:object} 200, not seen 200, seen 200, seen
D14-parameters-required-empty parameters {type:object, properties:{}, required:[]} 200, not seen 200, seen 200, seen
D15-openai-strict-shape strict true + {properties:{}, required:[], additionalProperties:false} 400 200, seen 200, seen 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
D16-parameters-absent parameters absent 200, not seen 200, seen 200, seen
D17-parameters-null parameters null 200, not seen 200, seen 200, seen
D18-description-absent description absent 200, not seen 200, seen 200, seen
D19-optional-timezone optional timezone property, call {} 200, not seen 200, seen 200, seen
D20-strict-timezone-nullable strict, timezone required as [string,null] 400 200, seen 200, seen 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
D21-tool-type-absent tools[0] without type 200, not seen 200, seen 200, seen
E1-args-empty-object arguments "{}" (base) 200, not seen 200, seen 200, seen
E2-args-empty-string arguments "" 400 200, seen 200, seen 0.10.0 only: empty-string history arguments are not an object (v0.10.0 GLM5NextPromptPolicy.swift:340-350)
E3-args-spaced arguments "{ }" 200, not seen 200, seen 200, seen
E4-args-newline arguments "{}\n" 200, not seen 200, seen 200, seen
E5-args-padded arguments " {} " 200, not seen 200, seen 200, seen
E6-args-null-string arguments "null" 400 400 400 history arguments must be a JSON object: decodeHistoryArguments (GLM5NextPromptPolicy.swift:476-478)
E7-args-object arguments as JSON object {} (not a string) 400 400 400 OpenAI spec violation: SDK OpenAIToolCall.Function.arguments: String (OpenAIProtocol.swift:339) fails decodeInboundChatRequest -> rejectInvalidRequest() (ProviderLoop+InferenceHandler.swift:351-363)
E8-call-index tool_calls[0].index 0 200, not seen 200, seen 200, seen
E9-call-type-absent tool_calls[0] without type 400 400 400 OpenAI spec violation: SDK OpenAIToolCall.type: String (OpenAIProtocol.swift:348) fails decodeInboundChatRequest -> rejectInvalidRequest() (ProviderLoop+InferenceHandler.swift:351-363)
E10-openrouter-id OpenRouter-style id "get_time:0" 200, not seen 200, seen 200, seen
F1-content-null content null (base) 200, not seen 200, seen 200, seen
F2-content-empty content "" 200, not seen 200, seen 200, seen
F3-content-absent content absent 200, not seen 200, seen 200, seen
F4-content-empty-parts content [] 200, not seen 200, seen 200, seen
F5-content-empty-text-part content [{type:text,text:""}] 200, not seen 200, seen 200, seen
F6-refusal-annotations refusal null + annotations [] 200, not seen 200, seen 200, seen
G1-result-string content plain string (base) 200, not seen 200, seen 200, seen
G2-result-json-string content JSON string 200, not seen 200, seen 200, seen
G3-result-parts content [{type:text,...}] 200, not seen 200, seen 200, seen
G4-result-name name get_time 200, not seen 200, seen 200, seen
H1-stream-usage stream true + stream_options.include_usage (base) 200, not seen 200, seen 200, seen
H2-non-stream stream false, no stream_options 200, not seen 200, seen 200, seen
H3-non-stream-with-options stream false + stream_options 200, not seen 200, seen 200, seen
H4-stream-absent stream absent 200, not seen 200, seen 200, seen
I1-max-tokens max_tokens 4096 200, not seen 200, seen 200, seen
I2-max-completion-tokens max_completion_tokens 4096 200, not seen 200, seen 200, seen
I3-sampling temperature 0, top_p 1, top_k 0, min_p 0, penalties 200, not seen 200, seen 200, seen
I4-seed-user seed 42 + user 200, not seen 200, seen 200, seen
I5-stop-array stop [] 200, not seen 200, seen 200, seen
I6-logprobs-false logprobs false 200, not seen 200, seen 200, seen
J1-openrouter-composite content "" + reasoning + Darkbloom-shaped reasoning_details + call index 0 + strict OpenAI shape + tool_choice auto + parallel true + reasoning {enabled:true} + max_tokens 400 200, seen 200, seen 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
J2-composite-details-only-effort details-only (two encrypted+text entries) + args "" + parameters {} + reasoning {effort:medium} 400 200, seen 200, seen 0.10.0 only: empty-string history arguments are not an object (v0.10.0 GLM5NextPromptPolicy.swift:340-350)
J3-composite-max-tokens-budget both reasoning fields + reasoning {max_tokens:4000, exclude:false} + strict + stream false 400 200, seen 200, seen 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
K1-first-turn user + get_time {type:object, properties:{}} 200 (call) 200 (call) 200 (call)
K2-first-turn-strict user + strict OpenAI-shape get_time + reasoning {enabled:true} 400 200 (call) 200 (call) 0.10.0 only: strict tool decoding is not qualified (v0.10.0 GLM5NextPromptPolicy.swift:266-268)
K3-first-turn-parameters-empty user + get_time parameters {} 200 (call) 200 (call) 200 (call)
K4-first-turn-effort-budget user + tools + reasoning {effort:high} + tool_choice auto 200 (call) 200 (call) 200 (call)

Tests. Each new test, and each new case in an extended test, fails on master's policy and passes with the fix:

  • GLM5NextPromptPolicyTests/reasoningContextRendersEveryGoldenLikeItsClearThinkingSpelling replaces each official golden's clear_thinking spellings with the equivalent reasoning.context. All seven goldens must still match byte for byte, including clear-historical-reasoning and clear-keeps-current-turn-reasoning.
  • currentTurnReasoningContextRendersLikeClearThinking: current_turn renders exactly like clear_thinking: true, with and without a later user turn.
  • reasoningContextContradictingClearThinkingIsRefused: refused on the coordinator and local paths.
  • GLM5NextOpenRouterCapabilityTests/openRouterSecretWordReasoningReturnIsServed runs the secret-word turn through the scheduler and service. It covers reasoning, Darkbloom-shaped reasoning_details and both carriers; strict plus "" arguments; and effort/max_tokens/include_reasoning/tool_choice/parallel_tool_calls/context/mode.
swift test --skip-build --filter 'GLM5NextOpenRouterCapabilityTests|GLM5NextPromptPolicyTests'
  master policy:  ✘ Test run with 42 tests in 2 suites failed with 14 issues: the 4 new tests, plus the new
                  context/mode cases of openRouterReasoningContentReturnRequestIsServed and
                  openRouterReasoningSwitchesAreNoOpsThatLeaveEveryGoldenRenderUnchanged
                  (Caught error: .invalidToolPayload("GLM5: controls require …"))
  this branch:    ✔ Test run with 42 tests in 2 suites passed
swift test --skip-build --filter 'GLM|Prompt|ChatTemplate|LocalChat|LocalResponse|ToolChoice|Inbound|ReasoningPrompt|ChatRequestExtraFields|NativeToolStream|ToolConstraint'
  ✔ Test run with 465 tests in 79 suites passed; XCTest: 5 MiMoV26PromptContractTests fail without MIMO_PROMPT_ARTIFACT_DIRECTORY (fixture precondition, same on master)
make docs-check            → docs-check: 196 file(s) OK
make docs-impact-check BASE=origin/master → canonical documentation coverage OK
make changelog-check       → 2 valid fragment(s)

Real GLM-5.3-Flash checkpoint: PASS.

  • Setup.

    • Host: M3 Ultra, holding the host's GPU lane (m5max-proof/lane_run.sh); 239 GB reclaimable, no Super or provider runner.
    • Weights: production bytes, aggregate 3aae613f…, re-verified by the managed load (134.5 s).
    • Build: this branch.
    • Path: GLM5NextRealModelHarness.chat, the production decode, policy, scheduler, real bridge with MTP and MLXOpenAIService. Scratch test, not in this PR.
  • Turn 1. Strict get_time; the model chose "penguin" while reasoning and called get_time with "{}".

  • Results.

    Turn 2 Answer
    OpenRouter-authored reasoning ("zephyr") as reasoning SECRET: zephyr
    as Darkbloom's reasoning_details entry SECRET: zephyr
    as both + reasoning: {enabled: true, context: "all_turns"} (needs this PR) SECRET: zephyr
    as reasoning + arguments: "" + {context: "current_turn", mode: "standard"} (needs this PR) SECRET: zephyr
    the model's own turn-1 reasoning and call returned SECRET: penguin
    control: no reasoning returned SECRET: banana (cannot see it)

Tiny synthetic GLM loaded by ProviderLoop.ensureModelLoaded: PASS.

  • Setup.
    • Gates: DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY=1, DARKBLOOM_CBV2_MTP=1, under the GPU lane.
    • Load: real managed load, production slot factory, protected native engine with MTP, shipped template.
    • Request path: handler order through the slot's bridge; 872-959 prompt tokens, 4 generated tokens.
  • On v0.10.1's policy:
    • Served: reasoning, reasoning_details, both with strict and "" arguments, encrypted and text details with parameters: {}, a budget with stream: false, and the control.
    • Refused with 400 at validateNativeControls: context: all_turns and context: current_turn + mode: standard.
  • On this branch: those two are served as well. mode: pro, exclude: true and a context contradicting clear_thinking stay 400.

Limitations.

  • The owner's screenshot shows only the start of OpenRouter's upstream body, so the matrix enumerates the documented shapes rather than replaying the captured request.
  • The matrix model is scripted, so it proves acceptance and rendering. The model's answer comes from the real-checkpoint run above.
  • The platform prompt sidecar's GLM mirror (coordinator/promptsidecar/src/glm5_next.rs, reasoning_members) still refuses context and mode. 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.md and docs/developer/test.md are 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.context rule twice:

    • validate() refused a context that contradicts the raw clear_thinking;
    • additionalContext() repeated that comparison against the typed controls' value, then resolved explicit ?? context ?? false separately.

    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-use contradictoryReasoningContext constant is inlined (1 file, +12/−10).

  • Reviewed, no change needed: the context/mode capture (noOpReasoningMembers and 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 isolated DARKBLOOM_STATE_FILE/DARKBLOOM_LOADED_MODELS_FILE/DARKBLOOM_VERIFIED_WEIGHTS_FILE:

    swift test --skip-build --no-parallel --filter 'GLM5NextOpenRouterCapabilityTests|GLM5NextPromptPolicyTests'
      ✔ Test run with 42 tests in 2 suites passed
        (every official and additional golden render, reasoningContextRendersEveryGoldenLikeItsClearThinkingSpelling
         and the 6 openRouterSecretWordReasoningReturnIsServed cases included)
    swift test --skip-build --no-parallel --filter 'GLM|Prompt|ChatTemplate|LocalChat|LocalResponse|ToolChoice|Inbound|ReasoningPrompt|ChatRequestExtraFields|NativeToolStream|ToolConstraint'
      with pinned MiMo metadata (MIMO_PROMPT_ARTIFACT_DIRECTORY):
      ✔ Test run with 464 tests in 78 suites passed (the broad run above minus its uncommitted scratch matrix suite)
      ✔ 3, 15 and 18 tests in the other bundles; XCTest: 27 executed, 3 skipped, 0 failures
    make docs-check                           → docs-check: 196 file(s) OK
    make docs-impact-check BASE=origin/master → canonical documentation coverage OK
    make changelog-check                      → 2 valid fragment(s); make changelog-preview OK
    
  • Sidecar parity follow-up: Layr-Labs/darkbloom-platform#461 (draft) mirrors these semantics in the prompt sidecar.

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 GLM5NextPromptPolicy request-control validation for glm5_next slots. No protocol, catalog, coordinator or release change.

… 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.
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Oct 24, 2026 7:06am UTC
d-inference-console-ui-dev Ready Ready Preview Oct 24, 2026 7:06am UTC
d-inference-landing Ready Ready Preview Oct 24, 2026 7:06am UTC
darkbloom-status Ready Ready Preview Oct 24, 2026 7:06am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 24, 2026 7:06am UTC

Request Review

…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.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

Superseded by #1592; consolidated per owner request

@jonathan308 jonathan308 mentioned this pull request Oct 24, 2026
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

5 active deployments
Preview – d-inference — cca4aa11 Deployed Oct 24, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — cca4aa11 Deployed Oct 24, 2026 by vercel[bot]
Preview – d-inference-landing — cca4aa11 Deployed Oct 24, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — cca4aa11 Deployed Oct 24, 2026 by vercel[bot]
Preview – darkbloom-status — cca4aa11 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant