Skip to content

fix(glm): GLM-5.3-Flash OpenRouter readiness: VFR video, strict tools and returned reasoning - #1561

Merged
Gajesh2007 merged 36 commits into
masterfrom
fix/glm-reasoning-history
Oct 23, 2026
Merged

Gajesh2007 merged 36 commits into
masterfrom
fix/glm-reasoning-history

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Consolidated GLM-5.3-Flash OpenRouter PR (owner decision: one PR per model). It now also carries #1559 (variable-frame-rate video, SDK pin 7bed8216 → 6aef0a5d from Layr-Labs/mlx-swift-lm#340) via signed merge 35d266de2. The OpenRouter capability work for GLM (JSON mode, structured outputs, forced tool_choice, logprobs and the native-mode refusal fix) is being merged into this branch as each part is proven. Sections for each part follow below.

Summary

Update: the strict gate is now proven against OpenRouter's real captured tool-test payloads. See Proven against captured OpenRouter tool payloads.

OpenRouter's reasoning-content-return readiness task fails on glm-5.3-flash with 400 invalid inference request (three runs on 2026-10-22, provider request ID lb52omhg0hnt). The same task passes on MiMo (mimo-v2.6-flash-mopd) and Nemotron Super.

The exact request payload was not observable. The OpenRouter dashboard shows status and the error body only: no request JSON, no provider request ID per run. This fix is built from the evidence below, not from a captured request.

  • The task carries tools. On 2026-10-15 the same task got the coordinator's tool capability 503 (CapabilityGate.Reject, which fires only when tools is present). Today it reaches the provider and gets invalid_request.
  • Every GLM task without tools passes: reasoning, reasoning-effort-low/high/max, multi-turn, multi-system-prompt, max-tokens, image and video URL.
  • So the failing request is OpenRouter's "preserving reasoning blocks with tool calls" turn: user → assistant tool call carrying its reasoning → tool result, with tools declared.

I pushed 50 candidate shapes of that turn through each family's real decode → policy path (GLM also through the pinned template). Using MiMo and Super as the benchmark, GLM refused six shapes that both of them serve:

GLM-only refusal (before) Shape Fix
strict tool decoding is not qualified "strict": true on a function: what OpenRouter's tool tests send (captured in platform incident_fixtures.go) Accept. GLM does not constrain decoding, but every auto call is already checked against its declared schema before it is exposed (ToolConstraintValidation.validate), so a non-conforming call still fails the request. The template omits strict
history arguments not an exact JSON object "arguments": "" on a returned call Read as {}, as vLLM, MiMo and Super do
controls refusal reasoning: null, include_reasoning: null Unset
controls refusal top-level thinking: {"type":"enabled","clear_thinking":false} (GLM's own API spelling) or a Boolean Thinking switch plus clear_thinking (lowest precedence)

strict: true is the most likely trigger: it is the only tool-specific GLM-only refusal, and OpenRouter's captured tool requests use it. The other three are fixed as well because the payload is unknown.

The fix also corrects a silent rendering gap. Reasoning returned as OpenRouter's reasoning string or reasoning_details text was dropped by the SDK message type, so GLM rendered an empty <think></think> for that turn. It now renders exactly as reasoning_content. Summary and encrypted details are skipped. clear_thinking semantics are unchanged.

Also, as Nemotron Super already does: null reasoning members are unset, and reasoning.summary / generate_summary levels (auto, concise, detailed) are no-ops.

Still refused: forced (required/named) tool choice, contradictory thinking switches, unknown reasoning members, preserve_thinking, hidden reasoning (reasoning.exclude: true / include_reasoning: false, same fixed message), forged schema markers and history whose tool results don't match their calls. Either MiMo or Super refuses each of these too, so none can be the passing task's shape.

Before

flowchart LR
  OR["OpenRouter<br/>reasoning-content-return<br/>(tools + returned reasoning)"]:::req --> C["Coordinator<br/>passes body through"]:::ok
  C --> D["decode + RawControls"]:::ok
  D -->|"thinking object / reasoning: null"| X1["invalid controls"]:::bad
  D --> P["GLM5NextPromptPolicy<br/>normalizedTextInput"]:::ok
  P -->|"strict: true"| X2["strict not qualified"]:::bad
  P -->|"arguments: \"\""| X3["history args refused"]:::bad
  P -->|"reasoning / reasoning_details"| E["dropped:<br/>empty &lt;think&gt;&lt;/think&gt;"]:::warn
  X1 & X2 & X3 --> R400["400 invalid inference request"]:::bad
  classDef req fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
  classDef ok fill:#e5e7eb,stroke:#4b5563,color:#111827
  classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
Loading

After

flowchart LR
  OR["OpenRouter<br/>reasoning-content-return<br/>(tools + returned reasoning)"]:::req --> C["Coordinator<br/>passes body through"]:::ok
  C --> D["decode + RawControls<br/>(+ returnedReasoning capture)"]:::new
  D --> P["GLM5NextPromptPolicy<br/>normalizedTextInput"]:::new
  P --> M["assistant turn gets<br/>reasoning_content"]:::new
  M --> T["pinned template<br/>&lt;think&gt;reasoning&lt;/think&gt;&lt;tool_call&gt;…"]:::ok
  T --> G["generate; every auto call<br/>schema-validated before exposure"]:::ok
  G --> R200["200 stream"]:::good
  D -.->|"contradictions, exclude, unknown keys"| R400["400 (unchanged)"]:::bad
  classDef req fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
  classDef ok fill:#e5e7eb,stroke:#4b5563,color:#111827
  classDef new fill:#dcfce7,stroke:#15803d,color:#14532d
  classDef good fill:#bbf7d0,stroke:#15803d,color:#14532d
  classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
Loading

Code flow (provider-swift/Sources/ProviderCore/Inference/Prompting/GLM5NextPromptPolicy.swift):

 RawControls.capture(from:)
+  returnedReasoning = messages[].reasoning ?? reasoning_details[reasoning.text].text
+  present(_:nullable:)  // null = unset for reasoning, its members, include_reasoning, thinking
-  "thinking" present → invalid
+  thinking: Bool | {type: enabled|disabled, clear_thinking: Bool}
-  reasoning keys ∉ {effort, enabled, exclude, max_tokens} → invalid
+  … unless null or summary/generate_summary ∈ {auto, concise, detailed}
 normalizedTextInput
-  any tool.strict == true → invalid
   validateHistory(messages)
+  assistant without reasoning_content ← returnedReasoning[index] (aligned with prepared.messages)
 decodeHistoryArguments
+  "" → [:]

Proven against captured OpenRouter tool payloads

OpenRouter's GLM capability tests fail with the same 400 invalid inference request, three runs each: tool-call-step-1, tool-call-step-5, tool-choice-auto and tool-choice-none. The platform conformance fixtures hold OpenRouter's real captured tool-test bodies (orIncidentOmitted, orIncidentAuto in coordinator/tests/internal/conformance/incident_fixtures.go): the Boston weather prompt with get_current_weather, "strict": true, additionalProperties: false, reasoning: {"enabled": false} and stream: true; tool_choice is omitted in one and "auto" in the other.

Commit c7bfab158 adds tests that replay those bodies byte for byte. Each is SHA-256-checked against the platform fixture's provenance hashes f0f8f60c… / d63598aa…; only the routed model is added, as the platform fixture wrapper does. The cases are tool choice omitted, auto, and the auto body with "tool_choice": "none", plus a five-step conversation built from the same strict tool (user, then five rounds of assistant tool_calls and tool result; two rounds return reasoning), the tool-call-step-5 shape. Each runs through GLM's real coordinator and local decode → controls → ToolChoicePromptPolicy.prepare → ToolStreamPreparation.makeHandler → GLM5NextPromptPolicy → shipped template path.

Before (GLM5NextPromptPolicy.swift at origin/master, same tests):

✘ capturedOpenRouterToolRequestIsServed(toolChoice: "omitted")  Caught error: .invalidToolPayload("GLM5: strict tool decoding is not qualified")
✘ capturedOpenRouterToolRequestIsServed(toolChoice: "auto")     Caught error: .invalidToolPayload("GLM5: strict tool decoding is not qualified")
✘ capturedOpenRouterToolRequestIsServed(toolChoice: "none")     Caught error: .invalidToolPayload("GLM5: strict tool decoding is not qualified")
✘ capturedOpenRouterToolServesAFiveStepConversation()           Caught error: .invalidToolPayload("GLM5: strict tool decoding is not qualified")
✘ Test run with 2 tests in 1 suite failed after 0.034 seconds with 4 issues.

invalidToolPayload maps to failure code invalid_request (ProviderLoop+ErrorMapping.swift), and the coordinator renders that as exactly OpenRouter's {"error":{"code":"invalid_request_error","message":"invalid inference request"}}.

After (this PR):

✔ Test capturedOpenRouterToolRequestIsServed(toolChoice:) with 3 test cases passed after 0.061 seconds.
✔ Test capturedOpenRouterToolServesAFiveStepConversation() passed after 0.069 seconds.
✔ Test run with 28 tests in 1 suite passed after 0.158 seconds.

The rendered prompts keep the declaration unchanged (closed schema included; strict is omitted by the template), close thinking for reasoning: {"enabled": false}, and for none drop the tools and add the no-call instruction. Focused reruns at c7bfab158: GLM5NextPromptPolicyTests 29/29, GLM5Next 112/0, LocalChatRequestTests 6/0, InboundDecodeTests 32/0, InboundChatRequestDecodeTests 4/0, MultiModelBatchSchedulerEngineTests 30/0, ToolChoicePromptPolicy 19/0, ToolConstraint 75/0, ProductionPromptParityTests 2/0, NemotronSuperPromptContract|NemotronSuperRequestPlan XCTest 15/0, MiMoV26TemplateFixTests 18/0. make docs-check, docs-impact-check.py --base origin/master and changelog.py check pass.

So the strict gate is proven to be the 400 for OpenRouter's tool tests. reasoning-content-return's exact payload is still unobserved. It carries tools (the 2026-10-15 tool-capability 503) and fails with the same error, and OpenRouter's tool tests declare this strict tool, so it very likely hits the same gate. Its other plausible extras (returned reasoning / reasoning_details, null fields, GLM's thinking object, "" arguments) are covered by the matrix below.

Out of scope here: response-format-json-object and structured-output are refused by GLM5NextPromptPolicy.normalizedTextInput's guard request.responseFormat?.requiresJSONOutput != true ("JSON output mode and constrained JSON schemas are not qualified" → invalid_request; verified locally for json_object and a strict json_schema). tool-choice-required and tool-choice-function stop at the coordinator. Neither is changed by this PR.

Evidence

Candidate matrix: the same tool-call turn (get_weather, returned call, tool result) with one variation per row. Each family ran its production decode and policy path in a temporary probe test (not committed): GLM decodeInboundChatRequest → validateNativeControls → prepare → ToolStreamPreparation.makeHandler → normalizedInput → shipped template; MiMo validateRawControls → … → normalizedInput; Super NemotronSuperRequestPlan → messages → makeHandler.

All 50 shapes: GLM before / after, MiMo, Nemotron Super
Shape (tool-call turn + tool result) GLM before GLM after MiMo Nemotron Super
R1 reasoning_details text (doc flow) ✅ ✅ + reasoning rendered ✅ ✅
R2 reasoning_content ✅ + reasoning rendered ✅ + reasoning rendered ✅ ✅
R3 reasoning string ✅ ✅ + reasoning rendered ✅ ✅
R4 reasoning + reasoning_details ✅ ✅ + reasoning rendered ✅ ✅
R5 all three ✅ + reasoning rendered ✅ + reasoning rendered ✅ ✅
R6 details summary+encrypted+text ✅ ✅ + reasoning rendered ✅ ✅
R7 details encrypted only ✅ ✅ ✅ ✅
R8 reasoning_content null ✅ ✅ ✅ ✅
R9 content '' + reasoning ✅ ✅ + reasoning rendered ✅ ✅
R10 content text + reasoning ✅ ✅ + reasoning rendered ✅ ✅
R11 content missing + details ✅ ✅ + reasoning rendered ✅ ✅
R12 refusal/annotations nulls ✅ ✅ + reasoning rendered ✅ ✅
S1 strict true ❌ strict tool decoding is not qualified ✅ + reasoning rendered ✅ ✅
S2 strict true + additionalProperties false ❌ strict tool decoding is not qualified ✅ + reasoning rendered ✅ ✅
S3 strict false ✅ ✅ + reasoning rendered ✅ ✅
S4 additionalProperties false ✅ ✅ + reasoning rendered ✅ ✅
S5 $schema key ✅ ✅ + reasoning rendered ✅ ✅
S6 nullable union type ✅ ✅ + reasoning rendered ✅ ✅
S7 no parameters ✅ ✅ + reasoning rendered ✅ ✅
S8 reserved marker (forged) ❌ reserved schema metadata ❌ reserved schema metadata ❌ tool schema contains reserved internal metadata ✅
C1 tool_choice auto ✅ ✅ + reasoning rendered ✅ ✅
C2 tool_choice none ✅ ✅ + reasoning rendered ✅ ✅
C3 tool_choice required ❌ inference-enforced tool_choice is unsupported for this model ❌ inference-enforced tool_choice is unsupported for this model ✅ ❌ inference-enforced tool_choice is unsupported for this model
C4 tool_choice named ❌ inference-enforced tool_choice is unsupported for this model ❌ inference-enforced tool_choice is unsupported for this model ✅ ❌ inference-enforced tool_choice is unsupported for this model
C5 parallel_tool_calls false ✅ ✅ + reasoning rendered ✅ ✅
C6 parallel_tool_calls true ✅ ✅ + reasoning rendered ✅ ✅
H1 tool message name matches ✅ ✅ + reasoning rendered ✅ ✅
H2 tool message name mismatch ❌ tool result name does not match its call ❌ tool result name does not match its call ❌ tool result name does not match its call ✅
H3 missing tool result ❌ history is missing a tool result ❌ history is missing a tool result ❌ all tool results must precede the next non-tool message or e ✅
H4 extra tool result ❌ tool results must match a preceding call ID exactly once ❌ tool results must match a preceding call ID exactly once ❌ tool results must match each preceding call ID exactly once ✅
H5 two calls, results reversed ✅ ✅ + reasoning rendered ✅ ✅
H6 arguments empty string ❌ history arguments require a complete, exactly representable ✅ + reasoning rendered ✅ ✅
H7 arguments {} ✅ ✅ + reasoning rendered ✅ ✅
H8 arguments pretty-printed ✅ ✅ + reasoning rendered ✅ ✅
H9 arguments with float and escaped slash ✅ ✅ + reasoning rendered ✅ ✅
H10 arguments object (not string) ❌ SDK decode: arguments must be a string ❌ SDK decode: arguments must be a string ❌ SDK decode: arguments must be a string ❌ SDK decode: arguments must be a string
H11 tool call index field ✅ ✅ + reasoning rendered ✅ ✅
H12 tool content parts ✅ ✅ + reasoning rendered ✅ ✅
H13 final answer then follow-up ✅ ✅ + reasoning rendered ✅ ✅
H14 tool call id with toolu_ prefix ✅ ✅ + reasoning rendered ✅ ✅
K1 reasoning max_tokens 2000 ✅ ✅ + reasoning rendered ❌ invalid or unsupported reasoning controls ❌ unsupportedControl
K2 reasoning enabled ✅ ✅ + reasoning rendered ✅ ✅
K3 reasoning null ❌ controls refusal ✅ + reasoning rendered ✅ ✅
K4 reasoning null members ❌ controls refusal ✅ + reasoning rendered ❌ invalid or unsupported reasoning controls ✅
K5 reasoning summary ❌ controls refusal ✅ + reasoning rendered ❌ invalid or unsupported reasoning controls ✅
K6 include_reasoning true ✅ ✅ + reasoning rendered ✅ ✅
K7 include_reasoning null ❌ controls refusal ✅ + reasoning rendered ✅ ✅
K8 thinking enabled object ❌ controls refusal ✅ + reasoning rendered ✅ ✅
K9 kwargs clear_thinking false ✅ ✅ + reasoning rendered ❌ invalid or unsupported reasoning controls ❌ unsupportedControl
K10 OpenRouter tool-test envelope ❌ strict tool decoding is not qualified ✅ + reasoning rendered ✅ ✅

Shapes returning invalid_request on GLM before and served after: S1, S2, H6, K3, K4, K5, K7, K8, K10. Of these, S1, S2, H6, K3, K7, K8 and K10 are served by both MiMo and Super. Every other GLM refusal is shared with MiMo or Super.

Committed regression tests (GLM5NextPromptPolicyTests), run on master source then on this branch:

master:  openRouterReasoningContentReturnRequestIsServed  11/13 cases fail
           ({} and {"reasoning":{"enabled":true}} with strict → "strict tool decoding is not qualified";
            reasoning:null, null members, summary, generate_summary, include_reasoning:null,
            thinking object/Boolean/null → controls refusal)
         returnedAssistantReasoningRendersLikeReasoningContent  6 issues (reasoning not rendered)
         emptyHistoryArgumentsRenderAsAnEmptyObject             fails (history arguments refused)
         thinkingObjectClearThinkingYieldsToTheOtherSpellings   fails
branch:  GLM5NextPromptPolicyTests 27/27 pass (13/13 parameterized cases)

Focused suites on this branch (swift test --skip-build --disable-xctest --filter …; counts are Swift Testing tests passed / failed):

Filter Result
GLM5NextPromptPolicyTests 27 / 0
GLM5Next 109 / 0
LocalChatRequestTests, InboundDecodeTests, InboundChatRequestDecodeTests 6 / 0, 32 / 0, 4 / 0
MultiModelBatchSchedulerEngineTests, ToolChoicePromptPolicy, ToolConstraint 30 / 0, 19 / 0, 75 / 0
Flint, NemotronSuper, PromptTokenCache, Qwen4Reasoning, LocalResponse 91 / 0, 14 / 0, 12 / 0, 12 / 0, 16 / 0
MiMoV26TemplateFixTests (XCTest) 18 / 0
StandaloneServer 75 / 1. The failure, standaloneServerStopAndWaitReleaseResidentBridgeAndSSDResources (exit test), fails identically with this PR's source change reverted, so it predates this PR

make docs-check, docs-impact-check.py --base origin/master and changelog.py check pass. MiMo fixture XCTests that need MIMO_PROMPT_ARTIFACT_DIRECTORY or payload fixtures were not configured locally; they report fixtureRequired.

Unchanged and still asserted: template SHA 46b2e213…, golden renders, thinking-off closing </think>, the fixed exclusion refusal message and its 400 invalid_request / client_error wire mapping.

Merge Danger

Door: two-way. This is a provider policy change with no protocol, persistence or model-artifact change; reverting restores the old refusals.

Blast Radius: GLM-only. Only GLM5NextPromptPolicy behavior changes; the model-blind capture records returned reasoning for every request but only GLM reads it.

  • strict: true is now served by validation, not constrained decoding. A model call that breaks the schema fails the request (generation failure) instead of being refused up front.
  • Rendering changes only for requests that return reasoning/reasoning_details: the earlier turn now replays its reasoning while clear_thinking is false, as reasoning_content already did. This changes those prompts' tokens and prefix-cache keys.
  • Platform sidecar parity (follow-up, not in this PR): coordinator/promptsidecar/src/glm5_next.rs still refuses strict, top-level thinking, null reasoning/include_reasoning and summary levels, and does not map reasoning/reasoning_details or "" arguments. The coordinator does not reject on that: such requests plan cold, so cache-aware routing and the first-content estimate fall back to the heuristic. docs/reference/api-contracts.md there still says the provider refuses these. A small companion platform PR should mirror this contract.
  • Not verified against live OpenRouter or on GLM hardware. Rerun reasoning-content-return after a provider release that includes this change.

Test plan

  • cd provider-swift && swift build --build-tests && swift test --skip-build --disable-xctest --filter GLM5NextPromptPolicyTests (master source: fails as above; branch: 27/27)
  • Focused suites listed above
  • Candidate matrix probe, before and after, GLM vs MiMo vs Nemotron Super
  • make docs-check, python3 scripts/docs-impact-check.py --base origin/master, python3 scripts/changelog.py check

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

  • No protocol/interface changes. The GLM request contract widens (documented in docs/reference/protocol-messages.md#glm-native-prompt-contract); the platform sidecar mirror is a follow-up (above).

Documentation impact

  • Canonical documentation updated: docs/reference/protocol-messages.md (GLM native prompt contract), docs/architecture/inference.md, docs/developer/test.md

Changelog

  • Added changelog.d/glm-openrouter-returned-reasoning.md; python3 scripts/changelog.py check passes.

Refactor Pass

Not run. AGENTS.md requires a dedicated refactor subagent before review, and this worker has no delegation tool. The coordinating session owns this gate. Suggested scope: GLM5NextPromptPolicy.swift (RawControls.capture, ReturnedReasoning, returnedReasoning(_:request:prepared:)), keeping GLM5NextPromptPolicyTests green.

Refactor pass (reasoning/strict part)

A dedicated refactor subagent reviewed 59893e574 and c7bfab158 (git diff cf3c45107 c7bfab158). For that part, this replaces the "Not run" note above. The #1559 VFR part had its own pass and was not reviewed here.

Outcome: no source change. Small test and doc cleanups in 5c73e5e91.

GLM5NextPromptPolicy.swift was reviewed and left unchanged:

  • RawControls.capture, ReturnedReasoning and returnedReasoning(_:request:prepared:) are cohesive.
  • Their comments match the behavior:
    • Tool choice none either appends its instruction to a leading system turn or inserts one at index 0, so the 0…1 offset is correct.
    • The template drops strict.
    • ToolConstraintValidation.validate checks every auto call against its schema before exposure.
  • normalizedTextInput was deliberately left alone so the stacked JSON-mode / forced-tool-choice branch merges cleanly.

Cleanups in 5c73e5e91:

  • docs/developer/test.md cited a test that does not exist, openRouterReasoningContentReturnRequestsAreServed. It now cites openRouterReasoningContentReturnRequestIsServed. It also now says the captured requests are held byte for byte and hash-checked; the replay re-serializes them with the routed model added, so "replay byte for byte" was imprecise.
  • docs/architecture/inference.md now cites GLM5NextPromptPolicy.RawControls.returnedReasoning instead of the ambiguous pair RawControls, returnedReasoning.
  • changelog.d/glm-openrouter-returned-reasoning.md now lists thinking: null among the unset values. That behavior was already implemented and tested.
  • GLM5NextPromptPolicyTests.swift:
    • The conversation helper's merged parameter is now named fields, because callers also pass tool_calls and content, not only reasoning.
    • Removed an unused controls binding in renderedThinkingOffToolRequest.
    • Removed a decodeOpenAIRequest call that remoteAndLocalInputs already makes.
    • No assertion, fixture, captured payload or hash changed.

All invariants hold:

  • strict is accepted, and every auto call is still schema-validated before exposure.
  • Empty-string arguments become {}.
  • Null reasoning, include_reasoning and thinking mean unset.
  • The thinking Boolean or object is accepted.
  • Summary levels are no-ops.
  • Returned reasoning still renders as reasoning_content.
  • Every other refusal is unchanged.
  • The template SHA, goldens and exclusion message are unchanged.
  • The captured payloads are still byte for byte and hash-checked.

Validation (head 5c73e5e91, SDK 6aef0a5d, isolated DARKBLOOM_STATE_FILE / DARKBLOOM_LOADED_MODELS_FILE):

  • Deleted the bundled mlx.metallib / default.metallib copies, ran swift build --build-tests (Build complete), then ../scripts/stage-test-metallib.sh <bin>.
  • Ran ../scripts/run-nested-suite.sh 'GLM5NextPromptPolicyTests|GLM5Next|ToolChoicePromptPolicy|ToolConstraint|ProductionPromptParityTests' --no-parallel:
    • ProviderCoreTests: 245 tests in 28 suites passed.
    • ProviderCoreFoundationTests: 6 tests passed.
    • 0 failures.
    • "Pinned GLM5 native prompt policy": 28/28 passed. The file has 28 @Tests before and after this pass. This includes all seven returned-reasoning/strict tests and their 13 + 3 parameterized cases.
    • The script still exits 1 because of its skip tripwire. 30 opt-in tests are skipped because their gates are unset: DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY, DARKBLOOM_TEST_GLM5_MANAGED_SYNTHETIC and GLM53_RAW_HEADER_FIXTURE_DIR. None of them is in a file this pass touched.
  • make docs-check: 192 files OK.
  • make changelog-check: 3 valid fragments.
  • make changelog-preview: ran successfully.
  • make docs-impact-check BASE=origin/master: 10 changed files, coverage OK.

Refactor pass (GLM JSON / forced tool_choice)

A dedicated refactor subagent reviewed 2d65e068b (JSON mode / structured outputs), e771f9615 (forced tool_choice), 1d011ce1f (native output-control evidence) and 17d1f6214 (JSON-mode returned reasoning) on the merged head 7b801ad9a. The platform mirror is reviewed in darkbloom-platform #411.

Outcome: one CI fix and a small behavior-preserving cleanup.

CI fix, 96c510158 (test(glm): align the capability tests with served GLM logprobs)

The merged logprobs commit f02327abe changed two things:

  • It added a capturesLogprobs argument to EngineV2Bridge.nativeOutputControlRefusal.
  • GLM's native engine now serves logprob rows.

GLM5NextOpenRouterCapabilityTests still called the old three-argument form, so the provider test products did not build on 7b801ad9a. Its control test also asserted that GLM refuses a logprobs row, which is no longer true. The fix keeps the evidence non-vacuous:

  • ServedResponse.nativeRefusals is still GLM's decision (capturesLogprobs: true). Every JSON and forced assertion that it is [nil] is unchanged.
  • New nonCapturingNativeRefusals holds the same check for a native engine that cannot capture logprobs (MiMo).
  • The control is renamed nativeEngineEvidenceAdmitsGLMLogprobsButRefusesNonCapturingEngines. It asserts that GLM admits the logprobs row and that the non-capturing engine refuses it with EngineV2Translation.unsupportedOutputControlPrefix.
  • A full swift build --build-tests found no other caller of the old signature.

Cleanup, 68593b595 (refactor(glm): name the withheld GLM output modes once)

  • New GLM5NextPromptPolicy.withholdsOutput(_:modelType:) names the requests whose output GLM withholds until it validates: a JSON response_format, or a required/named call. MultiModelBatchSchedulerEngine used to spell that set twice, once for the GLM media refusal and once for the text path's typed reasoning channel and withheld-output recording. Both now read the one predicate, so they cannot drift.
  • returnedReasoning renames its index to instructionIndex and says why the inserted turn is the last leading system turn.
  • docs/developer/test.md now describes the new control.

Reviewed and left unchanged:

  • GLM5NextResponseFormat / GLM5NextResponseFormatOutput.
  • The scheduler's emit withholding.
  • ToolChoiceEnforcementPolicy: forcedStrategy, validateParser and advertisesCapability.
  • The shared compileResponseSchema explicit-type check.
  • The named-choice tool filter.
  • EngineV2RequestUsageSignal.recordWithheldOutput.
  • The changelog fragment, protocol-messages.md, inference.md and the fixture README. inference.md is still accurate after served GLM logprobs: JSON and forced rows request no logprobs and install no constraint.

All invariants hold:

  • json_object / json_schema are served through the instruction plus withheld validation. One validated, fence-free answer is exposed. Prose, a schema violation or truncation is a 422 with nothing exposed.
  • Forced required/named choice uses the forcing instruction plus structured post-validation. A named choice offers only its function.
  • JSON with tools, unsupported schemas, and media with either mode stay 400.
  • No sampler constraint is installed, so MTP stays on.
  • Returned reasoning renders in JSON-mode multi-turn requests.
  • Forced choice is still advertised for glm-5.3-flash and the local qualification ID.
  • No test was removed or weakened.

Validation (SDK baca4acf, isolated DARKBLOOM_STATE_FILE / DARKBLOOM_LOADED_MODELS_FILE)

  • Before each build, deleted the staged mlx.metallib / default.metallib copies. Then ran swift build --build-tests (Build complete) and ../scripts/stage-test-metallib.sh <bin>.
  • Before the fix, on 7b801ad9a: GLM5NextOpenRouterCapabilityTests.swift:90: missing argument for parameter 'capturesLogprobs' in call.
  • The CI-fix tree 96c510158 alone: run-nested-suite.sh 'GLM5NextOpenRouterCapability|NativeOutputControlRefusal|GLM5NextLogprobs|GLM5NextPromptPolicy' --no-parallel ran 43 tests in 4 suites, all passed. The renamed control passed. The only skip is protectedNativeEngineServesRelayLogprobs, which is gated on DARKBLOOM_TEST_GLM5_MANAGED_SYNTHETIC and is not in this pass's files.
  • Final tree 68593b595: run-nested-suite.sh 'GLM5NextOpenRouterCapability|GLM5NextPromptPolicy|ToolChoice|ToolConstraint|NativeOutputControlRefusal|GLM5Next|GLM5ToolFailure' --no-parallel:
    • ProviderCoreTests: 287 tests in 35 suites passed. This includes "GLM-5.3-Flash OpenRouter capability requests", "Pinned GLM5 native prompt policy", "GLM5Next media routing", "GLM tool suffix validation", "Native model forced-tool enforcement", "OpenAI tool_choice prompt policy" and NativeOutputControlRefusalTests.
    • ProviderCoreFoundationTests: 6 tests passed.
    • 0 failures.
    • The script still exits 1 because of its skip tripwire. 31 opt-in tests are skipped because their real-artifact, protected-factory, managed-synthetic and residency gates are unset (DARKBLOOM_TEST_GLM5_*, DARKBLOOM_TEST_GLM_RESIDENCY_INTEGRATION, GLM53_RAW_HEADER_FIXTURE_DIR). None of them is in a file this pass touched.
  • make docs-check: 192 files OK.
  • make docs-impact-check BASE=origin/master: 30 changed files, coverage OK.
  • make changelog-check: 5 valid fragments.
  • make changelog-preview: renders the GLM JSON / forced fragment.
  • Not run: real-model GLM qualification and the GPU-gated suites above.

Refactor pass (logprobs P0 part)

A dedicated refactor subagent reviewed the merged native-engine logprobs code without changing behavior:

Outcome: one small source cleanup, 574096eb4. The rest is merges with the moving remote: a8619365d, 6e717ac19 and 053a69147 (the head of the pushed range 98210d6e0..053a69147).

  • In EngineV2Bridge+Submission.swift, the non-throwing submitTokenized wrapper had two identical catch bodies. Each turned a typed refusal (tokenBudgetExhausted, unsupportedOutputControl) back into its in-band marker. They are now one multi-pattern catch. Both throws finalize their prefix-cache lookup first, and fromSchedulerMessage maps each marker back to its error, so nothing changes for callers.

  • I dropped an earlier edit that derived nativeTracked from the bridge's existing tracksNativeShutdown. After f02327abe, nativeOutputControlRefusal binds the engine once for both nativeShutdownExecutionContractID and acceptsLogprobRows, so reusing tracksNativeShutdown no longer simplifies it.

  • Reviewed and kept as is:

    • nativeOutputControlRefusal, both the instance and the static version
    • unsupportedOutputControlPrefix and its fromSchedulerMessage case
    • the ProviderLoop+ErrorMapping cases
    • NativeOutputControlRefusalTests and GLM5NextLogprobsTests
    • the fixture, the changelog fragment and the docs

    No test, assertion or public contract changed. GLM5NextOpenRouterCapabilityTests belongs to the GLM-features refactor agent, and I did not edit it. Its fix 96c510158 came in through a merge.

The invariants hold, and the runs below check them:

  • MiMo logprobs, and token constraints on any native engine, get a typed 400 invalid_request (client_error) before any reservation, on both submit paths. These never count toward the error cooldown.
  • GLM logprobs are served:
    • one entry per generated token, with the requested alternatives;
    • the logprob row never drafts (proposedTokens == 0);
    • a later plain request still speculates.
  • In the SDK, a logprob row never speculates. EngineLoopV2.mtpBasicEligible rejects it, and without target-only media in the cohort, mtpRowsCanSpeculate keeps the whole GLM step target-only.

Observations I did not act on:

  • The SDK co-batch test protectedPagedEngineServesALogprobRowBesideAPlainRow uses maxSpeculativeBatch: 1. With two rows, the batch gate alone already blocks speculation, so no test pins "the batch decodes without MTP while a logprob row decodes"; the code enforces it structurally. Pinning it would need a harness with maxSpeculativeBatch of at least 2.
  • GLM no longer refuses, so the typed 400 on a real native bridge is now tested only through the static and classification tests. MiMo's refusal is checked in the SDK (below).

Validation

Provider runs used head 053a69147, SDK baca4acf, and isolated DARKBLOOM_STATE_FILE / DARKBLOOM_LOADED_MODELS_FILE:

  • I deleted the bundled mlx.metallib / default.metallib copies, ran swift build --build-tests (Build complete), then ../scripts/stage-test-metallib.sh <bin>.

  • With DARKBLOOM_TEST_GLM5_MANAGED_SYNTHETIC=1, I ran ../scripts/run-nested-suite.sh '…' --no-parallel over these suites:

    • NativeOutputControlRefusal, GLM5NextLogprobs, MultimodalErrorMapping, InferenceFailure, ErrorMapping
    • EngineDeadlineRetirementBridgeTests, which covers the folded catch's tokenBudgetExhausted path
    • bridge: EngineV2LogprobsPassthroughTests, EngineV2LogprobsChannelCapTests, EngineV2TranslationTests, EngineV2EventFramingTests, EngineV2HardeningTests, EngineV2LookupReceiptCoverageTests, EngineV2CancellationTests
    • scheduler: multiModelEngine*, multiModelDeadline*, fromSchedulerMessage*, platformTerminal*, *MapsToBadRequest
    • GLM5NextOpenRouterCapabilityTests

    Result: 87 tests in 13 suites plus the scheduler's free-function tests passed, with exit 0 and no skips. They include protectedNativeEngineServesRelayLogprobs and refusalIsATypedClientErrorOnBothSubmitPaths.

  • Before f02327abe, a temporary probe that was never committed drove the folded catch's unsupportedOutputControl path through the real protected GLM bridge's non-throwing submit. It produced one in-band marker, which maps to 400 invalid_request / client_error, with no native fault, and the engine kept serving.

  • In the SDK, after swift build --build-tests and staging:

    • MLX_ENABLE_TF32=0 ../../scripts/run-nested-suite.sh 'GLM5NextMTPTests/protectedPagedEngine' --no-parallel: 4 tests passed. They include protectedPagedEngineCapturesLogprobRowsOffSpeculation, for serial and rectangular verification, and protectedPagedEngineServesALogprobRowBesideAPlainRow.
    • 'CBv2LogprobsTests|CBv2MTPEngineMixedTests': 4 XCTest and 13 Swift Testing tests passed.
    • With offline MiMo fixtures from scripts/prepare-mimo-provider-fixtures.py and MIMO_V26_SERIAL_NATIVE_TESTS=1, CBv2NativeRequestRetirementTests/testZeroWorkIsAcknowledgedAndColdRefusalNeverRegisters passed. It confirms that a tracked MiMo engine still refuses a logprob row at submit.
  • make docs-check: 192 files OK.

  • make changelog-check: 6 valid fragments.

  • make changelog-preview: OK.

  • make docs-impact-check BASE=origin/master: 38 files, coverage OK.

  • GitHub shows all four new commits as Verified.

Page-cache admission

Merged from fix/provider-load-time-memory (4f04e6bd0, 57e3fb2ad) in 98210d6e0.

Problem. SystemMemory.availableBytes counted free + inactive pages only, so clean file page cache on the active queue counted as used. macOS drops that cache without compressing or swapping any process memory. After weight download, staging and hashing, a 256 GB M5 Ultra held about 250 GB of page cache (vm_stat: free 2.4 GB, active 55.7 GB, inactive 208.7 GB). It reported 170.8 GB usable and refused GLM-5.3-Flash's 185.4 GB cold load (178.9 GB model + 6.5 GB serving reserve) until sudo purge.

Fix. Under the default reclaimable policy, available = max(free + inactive, free − speculative + file-backed (external_page_count) + purgeable).

  • The page-cache measure counts no anonymous or compressed memory.
  • The max keeps the figure at or above free + inactive, so no host gets a stricter gate than before.
  • DARKBLOOM_MEMORY_AVAILABILITY=free-only is unchanged.
  • Load admission, KV budgets, cold-load capacity, darkbloom status and darkbloom doctor all read SystemMemory.availableBytes.

Unit tests (SystemMemoryTests):

  • hostOnePageCacheNoLongerBlocksTheGLMColdLoad replays the incident's vm_stat sample. Usable rises from 171.0 GiB to 211.5 GiB against 185.4 needed, and the load is admitted.
  • busySharedMacIsNeverStricterThanBefore keeps a shared M3 Ultra (mostly anonymous inactive memory) at its free + inactive figure, 93.0 GB.
  • anonymousMemoryStillRefusesTheGLMColdLoad and compressedAndWiredMemoryEarnNoCredit give anonymous, compressed and wired pages no page-cache credit. The GLM load stays refused when the same pages are process memory.

M5 Ultra proof (256 GB, real GLM-5.3-Flash weights, page cache filled to the incident's shape, no purge before start):

Before: v0.10.0 (master cf3c45107) After: this fix
darkbloom doctor FAIL: needs ~185.4 GB, 156.6 GB usable PASS: 213.0 GB usable
Provider startup Startup preload: 0 model(s) loaded Startup preload: 1 model(s) loaded
Plain request 503 "Provider capacity is temporarily unavailable." 200

Full M5 evidence (fill procedure, vm_stat samples, logs and binary hashes): M5 Ultra #1 before/after comment.

Before (page-cache admission)

flowchart LR
  S["Mach vm_statistics64 sample<br/>~250 GB page cache, much of it active"]:::warn --> M1["free + inactive<br/>active page cache counted as used"]:::bad
  M1 --> A["SystemMemory.availableBytes"]:::ok
  A --> C["load admission · KV budgets ·<br/>cold-load capacity · status · doctor"]:::ok
  C -->|"170.8 GB usable, 185.4 GB needed"| X["GLM cold load refused<br/>until sudo purge"]:::bad
  classDef ok fill:#e5e7eb,stroke:#4b5563,color:#111827
  classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
Loading

After (page-cache admission)

flowchart LR
  S["Mach vm_statistics64 sample<br/>~250 GB page cache"]:::warn --> M1["free + inactive"]:::ok
  S --> M2["free − speculative<br/>+ file-backed + purgeable<br/>no anonymous or compressed pages"]:::new
  M1 --> A["SystemMemory.availableBytes<br/>larger of the two"]:::new
  M2 --> A
  A --> C["load admission · KV budgets ·<br/>cold-load capacity · status · doctor"]:::ok
  C -->|"185.4 GB needed"| G["GLM cold load admitted<br/>with the page cache full"]:::good
  classDef ok fill:#e5e7eb,stroke:#4b5563,color:#111827
  classDef new fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
  classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
Loading

Refactor pass (page-cache admission)

A dedicated refactor subagent reviewed 4f04e6bd0 and 57e3fb2ad (git diff 4f04e6bd0~1 57e3fb2ad) on head 98210d6e0.

Outcome: a small behavior-preserving cleanup, ced5723d9 (refactor(memory): share the live Mach sample and drop the dead saturating sum), merged into the branch by signed non-force merge 94808688f.

  • New SystemMemory.vmStatistics() owns the live Mach HOST_VM_INFO64 sample. availableBytes() reads it, and livePageCountsKeepTheMachPartition now checks the partition on that same sample instead of its own copy of the unsafe-pointer sampler.
  • Removed saturatingSum. Each measure adds at most three 32-bit Mach counters, which cannot overflow UInt64. The byte conversion still saturates (reclaimable) or fails closed to 0 (free-only).
  • Code comments and docs/architecture/hardware-support.md now name free + inactive directly instead of as "the former" or "before" measure.
  • The freeForLoadGb parameter doc now cites SystemMemory.availableBytes for the policy. It used to say "free pages plus reclaimable page cache", which is wrong for free-only and for the free + inactive term.
  • The test helper hostOneSample(anonymousFileCache:) is now hostOneSample(asAnonymousMemory:). The flag means the same pages are process memory rather than page cache.

Reviewed and left unchanged:

  • availableBytes(stats:pageSize:policy:): the policy switch, nil (reclaimable) / zero (free-only) on sampling failure, and byte-overflow handling.
  • The speculative-page de-duplication in freeAndPageCachePages.
  • The consumers: every admission consumer still reads SystemMemory.availableBytes.
  • The changelog fragment, docs/reference/configuration.md and docs/provider/cli-reference.md. The two reference docs are accurate, and fix/provider-load-time-memory also edits them.

All invariants hold:

  • reclaimable = max(free + inactive, free − speculative + external_page_count + purgeable).
  • Anonymous and compressed memory earn no page-cache credit. free-only is unchanged.
  • No test was removed or weakened. hostOnePageCacheNoLongerBlocksTheGLMColdLoad, busySharedMacIsNeverStricterThanBefore, the anonymous/compressed tests, reclaimableIsTheLargerMeasureAndNeverMore and livePageCountsKeepTheMachPartition keep their assertions.

Validation (SDK baca4acf, isolated DARKBLOOM_STATE_FILE / DARKBLOOM_LOADED_MODELS_FILE)

  • In a fresh detached worktree, before each build, deleted the staged mlx.metallib / default.metallib copies. Then ran swift build --build-tests (Build complete) and ../scripts/stage-test-metallib.sh <bin> (mlx.metallib 156f2624…).
  • ../scripts/run-nested-suite.sh 'SystemMemory|GlobalKVCacheBudget|ModelLoadAdmission|ModelFit|UnifiedMemoryCap' --no-parallel ran on ced5723d9 and again on the merged head 94808688f:
    • 98 tests passed, with 0 failures and 0 skips. The script exited 0.
    • The named invariant tests passed, along with the free-only tests cohostReclaimablePagesCannotSatisfyFreeOnlyReserve, freeOnlySamplerFailsClosed, freeOnlyAtomicLoadClaimRejectsForeignReclaimCredit, freeOnlyRuntimeClaimCannotSpendReclaimableHeadroom and processBudgetFreeOnlyPolicyRejectsSharedHostLoadAndRechecks.
    • Test and assertion counts are unchanged in SystemMemoryTests, SystemMemoryAdmissionTests and GlobalKVCacheBudgetProcessTests: 12 / 3 / 9 tests and 43 / 11 / 66 #expect/#require calls.
  • The branch moved during the pass (053a69147, the logprobs refactor pass). Merge 94808688f adds only EngineV2Bridge+Submission.swift to this pass's tree. The rebuild and the focused suites above were rerun on it.
  • make docs-check: 192 files OK.
  • make docs-impact-check BASE=origin/master: 38 changed files, coverage OK.
  • make changelog-check: 6 valid fragments.
  • make changelog-preview: renders the page-cache fragment.
  • Not run: the full provider suite and a real-hardware rerun. The M5 proof above ran the pre-refactor fix 57e3fb2ad. This pass changes no behavior.

GPU wired-limit guidance

From 68267f0ae (feat(provider): give the macOS GPU wired-limit fix for GLM-5.3-Flash).

What it does. GLM-5.3-Flash's KV grant fills the 90% memory cap, so at full KV a 256 GB M5 Ultra plans about 247 GB of GPU memory. Under the macOS default (iogpu.wired_limit_mb=0) the GPU may use only Metal's recommended working set, about 222 GiB there, and Metal command buffers past it fail with "Insufficient Memory" (kIOGPUCommandBufferCallbackErrorOutOfMemory). The provider now tells the operator the fix the production hosts run. Recommended values: iogpu.wired_limit_mb = physical memory less 16 GiB = 245760, and both user wire limits = 95% of physical memory = 261134011596.

Doctor WARN detail line (glm wired limit, at macOS defaults):

GLM-5.3-Flash plans about 247 GB of GPU memory at full KV on this 256 GB Mac, and the macOS wired-memory limits are below the recommendation, so Metal command buffers can fail with "Insufficient Memory". Fix: sudo sysctl -w iogpu.wired_limit_mb=245760 vm.global_user_wire_limit=261134011596 vm.user_wire_limit=261134011596 (to keep it after reboot, see below)

Fix command:

sudo sysctl -w iogpu.wired_limit_mb=245760 vm.global_user_wire_limit=261134011596 vm.user_wire_limit=261134011596
darkbloom restart

The GLM-5.3-FLASH GPU WIRED-MEMORY LIMIT — ACTION RECOMMENDED block after the detailed checks also prints the current values and a copy-paste LaunchDaemon install (/Library/LaunchDaemons/com.layrlabs.glm53-wired-limits.plist, the production plist) that reapplies the values at boot. Once the values are set, the check is PASS and shows them. The check is doctor-only and is not in buildDoctorChecks, so darkbloom verify does not fail on it. No command runs sudo for you.

Where else it appears. start prints the one-line fix as a warning: when it would serve GLM below the values. status adds → fix: under a GLM load error that reports the Metal out-of-memory text. When a GLM load, startup preload (new injectable StartupPreloader onFailure hook), self-test or coordinator request fails with that text, the daemon logs the fix once per process to stderr, plus a fixed public line in the unified log. The error text is only matched, never logged. The provider's own lower-case "Insufficient memory for …" refusals never match.

Scope. GLM-5.3-Flash only, on 256 GB M5 Macs only. The check applies when GLM is downloaded, selected in [backend] or served. Other chips and sizes show nothing: at 512 GB the same rule would put the user wire limits below the GPU limit, which no host has run.

No capacity change. This is advice only. Admission, KV grants and capacity never read it.

Known limitation. GLM's native engine can report its in-SDK GPU out-of-memory failures without the MLX text (readback faults show up only as nativeWorkFailed), so the failure-time notice cannot match them. doctor and start check the live limits beforehand, so they still flag the problem before any failure.

Tests: GLM5NextWiredLimitTests (derivation, default vs production limits, byte-exact plist, OOM matching vs provider refusals, notice mapping), GLMWiredLimitAdviceTests (doctor WARN/PASS/skip, GLM-in-use detection, start and status notices) and a StartupPreloadTests case for onFailure.

Refactor pass (wired-limit notice)

A dedicated refactor subagent reviewed 68267f0ae on head aad442436.

Outcome: no change (justified). The diff is already small and well bounded:

  • GLM5NextWiredLimit (ProviderCore) owns the derivation, the sysctl/plist text and the OOM matcher.
  • GLM5NextWiredLimitNotice owns the once-per-process gate.
  • GLMWiredLimitAdvice (CLI) owns the doctor, start and status presentation.
  • The shared-file hooks are one-line calls (three in ProviderLoop+InferenceHandler.swift, one in ProviderLoop+Trust.swift), plus the defaulted onFailure dependency in StartupPreloader and one ProviderOperationalMessage case.

Reviewed and kept:

  • The unlocked reported pre-check and the GLM model check in GLM5NextWiredLimitNotice.report. They look redundant with notice(...), but they keep non-GLM failures and later failures from probing sysctl or Metal.
  • Limits.live() is evaluated eagerly in doctor, start and status. Each runs once per command, and a lazy variant would only add API surface.
  • The #"…"# line-array plist builder. It reads clearly, and a test pins it byte-for-byte to the production plist.

Invariants hold:

  • No capacity, admission or KV change.
  • Nothing runs sudo.
  • The notice fires once per process and carries no prompt or error text.
  • The matcher ignores the provider's lower-case "Insufficient memory" refusals.
  • Doctor is WARN at the defaults and PASS at 245760, and it is not in verify.
  • The plist is unchanged.
  • No test was touched.

Validation (fresh detached worktree at aad442436, staged metallibs deleted before the build, isolated DARKBLOOM_STATE_FILE / DARKBLOOM_LOADED_MODELS_FILE):

  • swift build --build-tests: Build complete. Then ../scripts/stage-test-metallib.sh <bin> (mlx.metallib 156f2624…).
  • ../scripts/run-nested-suite.sh 'GLM5NextWiredLimit|GLMWiredLimitAdvice|StartupPreload|ProviderLogger|Doctor|Status' --no-parallel exited 0 with no skips. It ran 74 + 1 + 87 tests (Swift Testing + XCTest), including both wired-limit suites and StartupPreloader.
    • The StartupPreload filter also matches two MiMo strict-quote startup tests. They need MIMO_V26_SERIAL_LOAD_FIXTURES, so the fixtures were first prepared with scripts/prepare-mimo-provider-fixtures.py, as CI does. Without them, those two tests fail on XCTUnwrap. That failure is unrelated to this commit.
  • Nothing was pushed, because the pass produced no commit. Head is still aad442436.
  • make docs-check: 192 files OK.
  • make docs-impact-check BASE=origin/master: 78 changed files, coverage OK.
  • make changelog-check: 8 valid fragments.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

… on GLM

OpenRouter's provider-readiness test input-video-base64 failed on
glm-5.3-flash with 400 invalid_media. The clip is a variable-frame-rate
QuickTime movie (211 frames in 10.833 s), and GLM5NextProcessor refused it
with unsupported("variable-frame-rate video"), which the scheduler maps to
multimodal_rejected and then invalid_media.

- Bump mlx-swift-lm to the GLM5Next decoder fix: frames are indexed in
  presentation order and timed by the track's average rate, as in the
  reference loader (Layr-Labs/mlx-swift-lm#340).
- Admit data:video/mov (OpenRouter's documented QuickTime label) and
  data:video/x-m4v on the shared media ingest. MemoryBackedVideoAsset
  still identifies MP4 or QuickTime from the bytes.
- Scheduler-level regression test with the real OpenRouter fixtures and a
  label-alias ingest test; docs and changelog fragment.
…Flash

OpenRouter's reasoning-content-return readiness task carries tools and
returns the model's reasoning on an assistant tool-call turn. GLM refused
it with 400 invalid_request while MiMo and Nemotron Super serve it.

Every GLM-only refusal of a shape both passing families accept is removed:

- strict tool declarations: served without constrained decoding; every
  auto call is already validated against its declared schema before it is
  exposed (ToolConstraintValidation.validate).
- empty-string history arguments read as {} (vLLM, MiMo and Super parity).
- reasoning: null, null reasoning members and include_reasoning: null are
  unset; reasoning.summary/generate_summary levels are no-ops.
- top-level thinking as a Boolean or GLM's API object
  {"type":"enabled"|"disabled","clear_thinking":Bool}.

Reasoning returned as OpenRouter's `reasoning` string or `reasoning_details`
text entries now renders as the template's reasoning_content instead of an
empty thinking block. Contradictions, unknown reasoning members,
preserve_thinking, forced tool choices and hidden reasoning stay refused.
@vercel

vercel Bot commented Oct 23, 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 23, 2026 5:27am UTC
d-inference-console-ui-dev Ready Ready Preview Oct 23, 2026 5:27am UTC
d-inference-landing Ready Ready Preview Oct 23, 2026 5:27am UTC
darkbloom-status Ready Ready Preview Oct 23, 2026 5:27am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 23, 2026 5:27am UTC

Request Review

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 09d72c8ae7d6 against base cf3c4510722a.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
First pass completed; selected deeper review is pending

Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: selected depth completed (43 batches); openai/gpt-6.1-sol: selected depth completed (35 batches)

LOW: Weight-hash verification cache keyed on stat metadata with no stated integrity protection

docs/reference/configuration.md:371 · A-004, ADV-001, T-012, T-027

The new `DARKBLOOM_VERIFIED_WEIGHTS_FILE` (`~/.darkbloom/verified-weights.json`) lets startup registration reuse a recorded weight hash instead of re-hashing when the stored device/inode/size/mtime/ctime match. The documented protection is only 'owner-only'. The owner is the provider operator (ADV-001), so the operator can hand-write a record for substituted weights, or edit the weights and restore their stat metadata under a manipulated clock or inode reuse. The provider would then register and advertise the previously verified hash without re-reading the bytes. This narrows the existing weight-substitution control (T-012/T-027) and adds a new operator-writable trust input. The same docs say a managed GLM load now publishes its own per-file SHA-256 verification 'instead of bracketing passes', which drops the pre/post-load comparison. The threat model should record that this cache is self-attested local state, not an integrity proof, and that coordinator-side hash checks must not treat it as stronger evidence. If the cache is intended as a security control, it should be MAC-bound to the Secure Enclave-rooted KEK or limited to non-security fast paths.

Raised by: anthropic/claude-sonnet-5.5

LOW: Default reclaimable policy now credits all file-backed and purgeable pages as available memory, loosening the load/KV admission clamp

provider-swift/Sources/ProviderCore/Inference/Memory/SystemMemory.swift:62 · new attack surface

On the default `reclaimable` policy, `availableBytes` now returns max(free+inactive, free−speculative+external_page_count+purgeable_count) (SystemMemory.swift lines 60-62, 83-86). `external_page_count` covers every pageable file-backed page, including actively mapped pages that other processes or this process are still using, plus dirty pages that need writeback. The code comment claims reclaiming this memory never compresses or swaps process memory. That holds only for unmapped clean cache. Active mapped pages must be refaulted, and dirty pages need writeback first. The value feeds `ModelLoadAdmission.freeForLoadGb`/`maxLoadableWeightGb`, which clamp the load gate and the advertised loadable weight. Heavy file-cache or mapped-file use on a shared host can therefore inflate the headroom, so the provider admits a load or KV growth that pushes the machine into swap or OOM pressure and degrades availability. The cost is lost availability and over-advertised capacity. Mitigation: credit only a conservative fraction of `external_page_count`, or only inactive file pages, or keep the stricter policy on shared hosts. The existing `free-only` option remains available.

Raised by: anthropic/claude-sonnet-5.5

MEDIUM: Operator-writable verified-weight cache may let forged records bypass startup weight re-hashing

docs/reference/configuration.md:371 · A-004, ADV-001, T-012, T-027, T-041, TB-003

configuration.md head line 371 documents a new DARKBLOOM_VERIFIED_WEIGHTS_FILE (~/.darkbloom/verified-weights.json). It holds owner-only records of verified weight hashes, bound only to file metadata (device, inode, size, mtime, ctime). Startup registration reuses a matching record instead of re-hashing. Under TB-003 the operator (ADV-001) owns this file. The operator can also read every metadata field of a substituted weight file, ctime included. Unless records are MAC'd or signed under an SE-rooted or process-held key, an operator could write a record that pairs the substituted files' metadata with the expected aggregate hash. The genuine signed binary would then report that hash at registration without hashing the bytes. This would weaken the T-012/T-027 weight-substitution detection on A-004. Today an attested binary computes the hash itself; with a forged record it would advertise a hash for weights it never measured. The env override also lets the path point to any file the operator writes. Fix: authenticate each record, e.g. HMAC under a KEK-derived key (as KVCacheSSD does), and bind it to the binary or version. Also keep fresh hashing on load before a verified weightHash is published or used as the T-041 SSD binding. Then update T-012/T-027 to describe this cache. The implementation (VerifiedWeightHashStore.swift) was not supplied, so the missing integrity control is inferred from the documentation.

Raised by: anthropic/claude-opus-5.5

LOW: Registration weight hash can come from an unauthenticated, operator-writable cache file

provider-swift/Sources/ProviderCore/Service/VerifiedWeightHashStore.swift:84 · A-004, ADV-001, T-012, T-027, TB-003

VerifiedWeightHashStore (lines 47-54, 79-86, 110-116) returns a stored aggregate SHA-256 as a verified hash when stat() identities match. The JSON at installDirectory/verified-weights.json, or any path named by DARKBLOOM_VERIFIED_WEIGHTS_FILE, has no MAC or signature. An operator (ADV-001) can write a record whose file identities match tampered weights and whose aggregateSHA256 is the catalog value. Device, inode, size, mtime and ctime are all read from the operator-controlled filesystem. A startup registration path that consults this store would then report a manifest-matching weight hash without reading the bytes. Before this PR, the attested process had to hash the weights itself to produce that claim (T-012/T-027/T-034). The doc comment (lines 12-15) says the managed GLM load re-verifies before serving, so the expected impact is a false registration and routing claim plus load-time failure, not unverified bytes in service. That guarantee depends on callers outside this batch. Plausible trigger: edit verified-weights.json or set the env override, then restart. Fix: authenticate records with a key derived from the SE-rooted KEK, ignore the environment override in release builds, or never surface stored hashes as attested registration evidence. Also update T-027/T-012 to describe the cached claim.

Raised by: anthropic/claude-opus-5.5

Scan incomplete: 1 file(s) could not be fully read as text. Binary, Git LFS and submodule changes require manual review.
Affected files: libs/mlx-swift-lm

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Human review required: CI did not complete the security review. A maintainer must review the saved findings and remaining scope. A green advisory job is not security clearance; do not manually rerun the paid scan.

Coverage: 373/373 source units; cross-file integration complete. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 147 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Bedrock: 7 request(s), 242423 uncached + 0 cache-read + 64267 cache-write input / 7303 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately.
Workload allowance: 155 native request(s), including one shared response repair; 500 emergency ceiling. Selected depth and integration rounds are admitted as their scope becomes known.

… the changelog

Required refactor pass; no behavior change.

- Bump libs/mlx-swift-lm 54227bab -> 6aef0a5d (Layr-Labs/mlx-swift-lm#340),
  which removes decodeFrames' frame-rate parameter left unused by the
  variable-frame-rate fix and updates two comments that still described
  constant-frame-rate-only decoding.
- The shared inline-video path also serves MiMo V2.6:
  MiMoV26EncodedMediaIngress calls MediaIngest.decodeVideo directly, so it
  admits the new video/mov and video/x-m4v labels too. Say so in the
  changelog fragment.
Owner decision. OpenRouter sends data:video/quicktime;base64, which every
model already admits: Nemotron Super passed OpenRouter's base64 readiness
test with OpenRouter's label, and the recorded request size fits that
28-character header exactly. The aliases also made the shared ingest accept
labels that Nemotron Super, in the provider and the coordinator, still
refuses.

- MediaIngest.decodeVideo again admits only data:video/mp4;base64 and
  data:video/quicktime;base64; MediaIngest.swift, MediaIngestTests.swift and
  the T-050 threat-model wording match master.
- The routing test keeps the real video/quicktime and video/mp4 readiness
  cases and drops the video/mov variant.
- Docs and the changelog fragment keep only the variable-frame-rate fix.
  The SDK pin and the GLM regression test are unchanged.
…the GLM path

The platform conformance fixtures hold OpenRouter's real tool-test bodies
(orIncidentOmitted, orIncidentAuto): the Boston weather prompt with a
strict, closed-schema get_current_weather tool and reasoning disabled.
Replay both byte for byte (hash-checked), the same body with tool_choice
none, and a five-step tool conversation built from them, through the
coordinator and local decode paths, the tool-stream handler, the GLM
policy and the shipped template. On master's policy every case fails with
"strict tool decoding is not qualified" (invalid_request); with the fix
they render.
Behavior-preserving refactor pass over the reasoning/strict commits. Correct the stale test name in docs/developer/test.md and say the captured requests are held byte for byte and hash-checked, cite RawControls.returnedReasoning precisely, list thinking: null in the changelog, name the conversation helper's merged assistant fields, drop an unused controls binding and a decode that remoteAndLocalInputs already performs.
…comments

Behavior-preserving refactor pass over the GLM startup-read and
page-drop work.

- StandaloneServer requires the managed load's verified hash through
  ProviderLoop.requireGLM5NextLoadedArtifact, the rule ProviderLoop
  already applies, instead of a second inline copy. The comparison and
  the thrown identityMismatch are unchanged.
- GLM5NextManagedLoad.verifiedArtifactSHA256 says core files are
  verified before any header or payload is read, as the native reader
  does. The duration formatter is private.
- VerifiedWeightHashStore names both writers: a full startup
  registration hash and a managed load's manifest verification.
- verifiedGLM5NextWeightHash's comment no longer hardcodes 182 GB; the
  changelog fragment's word order is fixed.
…penRouter PR

Brings f663fe2, a811ae2 and 43d5512 from fix/provider-load-time-memory: GLM startup reads its weights twice instead of five times (the load publishes its own SHA-256 verification as the weight hash; a verified-hash record keyed by device/inode/size/mtime/ctime serves restarts), and bulk hash/verify reads drop their cached pages afterwards. Owner-approved.

Resolves a semantic merge hazard: both sides added <think>/</think> to the synthetic GLM fixture vocabulary (4/5 here, 154841/154842 there), which would crash at runtime on a duplicate dictionary-literal key. Keeps the real GLM-5.3-Flash IDs 154841/154842 pinned in fixtures/models/glm53-flash/architecture.json.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

GLM startup timing on M5 Ultra #1: fix/provider-load-time-memory a811ae21a vs master

Same drain as the comment above (M5 Ultra #1, 256 GB, macOS 27.0.1, real GLM-5.3-Flash weights, aggregate 3aae613ff188bb0f…). sudo purge before every start, so every run read the weights from SSD. Timelines come from each provider's own log (glm_load_timeline.py).

Result. The weights are now read twice per start instead of four times (standalone) or five times (coordinator mode). With a warm shader cache, standalone ready goes from 122.0 s to 71.0 s. A coordinator-mode first start goes from 157 s to 107 s, and a restart that reuses the verified-hash record goes to 83 s. The managed load itself (SHA-256 verification + tensor reads, about 64 s) is unchanged. What was removed is every separate WeightHasher pass: 25 s each.

Binary Source darkbloom SHA-256 mlx.metallib
BEFORE master cf3c45107 (SDK 7bed8216) db94f6099b9f48d8892bb1f24aff92dfb56b2977f61206b77a8d80deb2e5beed 156f2624…
AFTER fix/provider-load-time-memory a811ae21a (= cf3c45107 + 4f04e6bd0, 57e3fb2ad, f663fe2ef, a811ae21a; SDK 7bed8216) f251c5dc094377fef378df6ef7dfa7b937d61df9c0a3b542bc2676e794bbcd95 156f2624…

Release, dev install identity, same build recipe as above (Xcode 27.1, Swift 6.4, SDK 27.0).

Standalone (glm_load_timeline.sh: start --local, GLM startup preload, production [backend] settings)

Offsets are seconds from process start (seconds spent).

Phase tl-before-1 BEFORE tl-after-1 AFTER tl-after-2 AFTER
Pre-load WeightHasher pass 6.0 (25.0) none none
Loader: auxiliary verify / core SHA-256 verify / tensor reads + construction 31–95 (64, not split in the log) 5.7: 0.1 / 15.3 / 48.0 (64.3 total) 5.5: 0.1 / 15.3 / 47.3 (63.5 total)
Post-load WeightHasher pass 95.0 (25.0) none none
Shape warmup 121.5 (0.5, skipped: warm shader cache) 70.8 (17.2, cold shader cache for the new binary) 70.5 (0.5, skipped: warm shader cache)
Ready (listening) 122.0 88.0 71.0
Full 182 GB reads 4 2 2

tl-before-1 vs tl-after-2 is like for like, both with a warm shader cache: −51.0 s. With a cold shader cache, AFTER takes 88.0 s (tl-after-1). The BEFORE cold-shader-cache starts on this Mac took 142 s (glm-before, 20:07 today, 20.1 s warmup), so the cold-cache comparison is 142 → 88 s. tl-after-2 is a standalone repeat. Standalone mode never registers, so it cannot exercise the verified-hash record; the coordinator-mode runs below do.

Coordinator mode (start --foreground --model glm-5.3-flash against the loopback proof coordinator from the comment above)

The production glm-5.3-flash revision directory was read-only. Ready = the provider's register + first heartbeat with glm-5.3-flash warm, as seen by the loopback coordinator.

Phase coord-before BEFORE coord-timing-1 AFTER, first start coord-timing-2 AFTER, restart
Registration hash (attachWeightHashes) 3.0 (25.0) 3.0 (25.0), no record yet 4.0: reused, "recorded by its last full verification; file identities unchanged, the load verifies again before serving"
Pre-load WeightHasher pass 31.0 (25.0) none none
Loader: aux / core SHA-256 / tensors + construction 56–120 (64, not split) 31.5: 0.1 / 15.3 / 47.2 (63.5 total) 6.6: 0.1 / 15.3 / 47.1 (63.4 total)
Post-load WeightHasher pass 120.0 (25.0) none none
Shape warmup 146.5 (0.5, warm cache) 96.5 (0.5, warm cache) 71.5 (0.5, warm cache)
Registered, warm 157 107 83
Full 182 GB reads 5 3 2
Plain request after warm 200 "OK" 200 "OK" 200 "OK"

All three runs spend about 10 s between the warmup and register, which this change does not touch. The verified-hash record went to the run's own file through DARKBLOOM_VERIFIED_WEIGHTS_FILE, not to ~/.darkbloom. It holds glm-5.3-flash → 3aae613f… with each file's device, inode, size, mtime and ctime. coord-timing-2 matched it after a purge, and its load still SHA-256-verified all 42 files before serving.

Wired limit (iogpu.wired_limit_mb, read with darkbloom doctor, no model loaded)

iogpu.wired_limit_mb doctor
245760 (current, persisted by /Library/LaunchDaemons/com.layrlabs.glm53-wired-limits.plist) [PASS] metal gpu: Apple M5 Ultra, 240 GB working set
0 (OS default), 21:00:36–21:00:50 only [PASS] metal gpu: Apple M5 Ultra, 222 GB working set
restored to 245760 at 21:00:50 sysctl iogpu.wired_limit_mb → 245760 (verified)
Harness and raw logs

glm_load_timeline.sh / glm_load_timeline.py / TIMELINE.md (standalone runs); serve_coord.sh + loopback_coordinator.py (coordinator runs; VERIFIED_WEIGHTS_FILE keeps the record between the two AFTER runs). AFTER GLM load log lines, verbatim:

tl-after-1     2026-10-22T21:04:12-0700 GLM load EigenLabs/GLM-5.3-Flash-MLX-NVFP4-mtp: all 42 manifest files SHA-256 verified before serving; auxiliary verification 0.1 s, core verification 15.3 s, tensors and construction 48.0 s, total 64.3 s
tl-after-2     2026-10-22T21:05:57-0700 GLM load EigenLabs/GLM-5.3-Flash-MLX-NVFP4-mtp: all 42 manifest files SHA-256 verified before serving; auxiliary verification 0.1 s, core verification 15.3 s, tensors and construction 47.3 s, total 63.5 s
coord-timing-1 2026-10-22T21:08:03-0700 GLM load glm-5.3-flash: all 42 manifest files SHA-256 verified before serving; auxiliary verification 0.1 s, core verification 15.3 s, tensors and construction 47.2 s, total 63.5 s
coord-timing-2 2026-10-22T21:08:48-0700 Weight hash for glm-5.3-flash: 3aae613ff188bb0f (recorded by its last full verification; file identities unchanged, the load verifies again before serving)
coord-timing-2 2026-10-22T21:09:54-0700 GLM load glm-5.3-flash: all 42 manifest files SHA-256 verified before serving; auxiliary verification 0.1 s, core verification 15.3 s, tensors and construction 47.1 s, total 63.4 s

GLM's KV grant fills the 90% memory cap, so at full KV a 256 GB M5
Ultra plans about 247 GB of GPU memory. Under the macOS default
(iogpu.wired_limit_mb=0) the GPU may use only Metal's recommended
working set, about 222 GiB there, and command buffers past it fail with
"Insufficient Memory" (kIOGPUCommandBufferCallbackErrorOutOfMemory).
Capacity and admission stay as they are; the operator gets the exact
fix the production hosts run instead.

GLM5NextWiredLimit derives the recommendation from physical memory
(iogpu.wired_limit_mb = physical less 16 GiB = 245760, user wire
limits = 95% = 261134011596) and defines it only for 256 GB M5 Macs:
at 512 GB the same rule would put the user wire limits below the GPU
limit, which no host has run. It reads the three sysctls and Metal's
working set, builds the sysctl one-liner and the LaunchDaemon that
reapplies it at boot, and recognizes MLX's Metal out-of-memory text
without matching the provider's own "Insufficient memory" refusals.

- doctor adds `glm wired limit` when GLM is downloaded, selected or
  served on such a Mac: WARN with the planned GPU memory and the
  one-liner, plus an action block with the current values, the fix,
  `darkbloom restart` and the copy-paste LaunchDaemon install; PASS
  with the current values once set. It is not in buildDoctorChecks, so
  `verify` does not fail on it.
- start prints the same one-line fix as a warning when its selection
  would serve GLM below the values.
- status adds `→ fix:` under a GLM load error that reports the Metal
  out-of-memory error.
- A GLM load, startup preload, self-test or coordinator request that
  fails with that error logs the fix once per process to stderr
  (provider.log, or a foreground start's terminal) and a fixed public
  pointer to the unified log. Error text is only matched, never logged.
  StartupPreloader reports through a new injectable onFailure hook.

Failures that the native engine reports without the MLX text (its
readback faults surface only as nativeWorkFailed) cannot be matched;
doctor and start still flag the limit there.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

GLM-5.3-Flash real-checkpoint logprobs qualification on M5 Ultra #1: FAIL

  • Build: feat/glm-logprobs-qual @ e0a353b21ebe9a3a7ac0da32963d69385a8e38d9 (the current branch head; contains e0a353b21). This is a DEBUG test build (swift build --build-tests plus scripts/stage-test-metallib.sh), because the test hooks are #if DEBUG. Built with Xcode 27.1 (27A9275) and Swift 6.4. ProviderCoreTests sha256 3b254f3a…fb56c, metallib 156f2624…462d.
  • Host: M5 Ultra DGInf: Decentralized private AI inference platform #1, 256 GB. Production was drained (0 unfinished requests, coordinator ack received) and purge ran before the test. GLM load took 72.6 s with all 42 manifest files SHA-256 verified.
  • Run: runs/glm-logprobs-qual-20261022-214121. The single test failed after 102.6 s with 5 issues. Tolerance was 5e-2 nats.
Check Result Numbers
1. Logprobs vs. teacher-forced reference ❌ Returned 32 entries, soloLogprobsDrafted=0 (it never drafted, as required). Steps 0–3 have no failures. The run reported 252 failures from step 4 onward, maxChosenDelta=0.399, maxTopDelta=15.75
2. Logprobs greedy == MTP greedy ❌ The outputs diverge at step 3: logprobs row # The History of the Roman Empire, MTP row # The Roman Empire: A Comprehensive History. MTP speculated: 15 rounds, 17 proposed, 15 accepted (acceptance 0.88)
3. Batched with a 128-token plain row ❌ The batched plain row also flipped to # The History of… (batchedPlain.text != plainSolo.text). batchedLogprobDrift=0.1075, above 0.05. MTP still drafted: 6 tokens before and 137 after the logprobs row finished
4. No native fault / bridge owns engine / no retained load ✅ (no issue recorded) Only the four expectations above failed, plus the run-level summary

Reading: the first divergence is a greedy argmax flip at a near-tie at step 3 ( Roman vs History). Step 3 itself passes the top-5 tolerance check, so both candidates sit inside 5e-2 of the reference. After step 3, check 1 compares the logprobs row with a reference that is teacher-forced on the MTP-decoded prefix (it expects Empire, :, A, Comprehensive…). So almost all of the 252 failures, and the 0.399 and 15.75 maxima, come from the misaligned prefix, not from per-step logprob error. The non-MTP paths (the solo logprobs row and the batched plain row) both choose History, while MTP and solo plain choose Roman. That is a path-dependent near-tie flip, so the "identical greedy text" assumption doesn't hold on this prompt. Fixing it needs a prompt without near-ties, a reference teacher-forced on the logprobs row's own tokens, or both. The batchedLogprobDrift of 0.1075 is the one number that isn't explained by prefix misalignment, and it exceeds the 0.05 bound.

Production: M5 #1 was drained at 21:41:19 PDT and darkbloom start --model glm-5.3-flash ran at 21:43:13. At 21:46:19 PDT it was verified with Warm models: glm-5.3-flash, "App Attest authorizes this connection", 0 doctor FAIL lines, and iogpu.wired_limit_mb=245760. Downtime was about 5 min. M5 #2, the catalog and the coordinator were not touched.

@jonathan308

Copy link
Copy Markdown
Collaborator Author

Merge order for review (for Gaj)

  1. Merge fix(glm5next): sample variable-frame-rate video at the track's average rate mlx-swift-lm#340 (SDK). It doesn't need a review.
  2. I then push one signed commit here that re-pins libs/mlx-swift-lm to fix(coordinator): schedule the read-cache purge janitor #340's squash commit on main, and CI reruns. Please approve this PR after that push: the ruleset dismisses approvals on new pushes.
  3. fix(nemotron-super): OpenRouter readiness: inlined video above 8 MiB, JSON response format with tools #1560 (Super) is green and can be approved and merged any time. It merges cleanly with this PR in either order.
  4. darkbloom-platform#411 (coordinator): merge it and deploy it before tagging provider 0.10.1. Its logprobs guard is what keeps logprobs requests away from providers.
  5. After this PR and fix(nemotron-super): OpenRouter readiness: inlined video above 8 MiB, JSON response format with tools #1560 merge, I open "Prepare provider 0.10.1" (the version bump).

Logprobs are included but stay off. The GLM logprobs code in this PR doesn't serve traffic until the build's catalog capabilities lists "logprobs". Don't add that yet: the real-model check failed (results in the comment above), and the cause is being diagnosed for a follow-up PR. Super logprobs aren't in #1560 and will also come as a follow-up.

Layr-Labs/mlx-swift-lm#340 was squash-merged to main as 6148b6da7eb8ed509ac56b74d7a69e8e73d8bf6c. Its tree is identical to the previously pinned PR head baca4acf8f7b4b91190de78a79e245f433875400, so only the gitlink changes: no SDK source differs.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

Re-pin pushed: 09d72c8. It's a signed commit that changes only the gitlink: libs/mlx-swift-lm moves to 6148b6da, the commit #340 was squash-merged as on mlx-swift-lm main. That commit's tree is byte-identical to the previously pinned PR head baca4acf, so no SDK source changes from what CI and the real-model proofs ran on.

CI is rerunning on 09d72c8; it took about 17 minutes last time. Please approve and merge once it's green. No more pushes to this branch are planned.

@jonathan308

Copy link
Copy Markdown
Collaborator Author

Disclosure for review: one stale gated test, which CI doesn't run.

ordinaryFactoryRunsTextHTTPImageAndProtectedEmbeddedMTP only runs with DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY=1, so CI never runs it. It still expects GLM to refuse tool_choice: required. This PR now serves required and named tool choice instead: the forcing instruction is rendered, the call is withheld until it parses and matches the declared schema, and anything else fails with 422.

So the test's expectation is out of date; the behavior isn't wrong. To avoid another push here during review, the fix goes in the logprobs follow-up draft (#1564). No CI result on this PR is affected.

This branch was successfully deployed

5 active deployments
Preview – d-inference — 09d72c8a Deployed Oct 23, 2026 by vercel[bot]
Preview – d-inference-landing — 09d72c8a Deployed Oct 23, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 09d72c8a Deployed Oct 23, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 09d72c8a Deployed Oct 23, 2026 by vercel[bot]
Preview – darkbloom-status — 09d72c8a Deployed Oct 23, 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.

2 participants