Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.d/reasoning-effort-every-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Every model that reasons takes every reasoning effort a client sends

- `reasoning_effort` and `reasoning.effort` take `none`, `minimal`, `low`, `medium`, `high`, `xhigh` and `max` on every model that reasons, on one Mac, on a pair and through the coordinator. Each becomes the model's nearest level, the higher one between two: `minimal` its lowest, `max` its highest, `none` thinking off where the model can.
- Qwen 3.8 27B (and the owned Flash-Next build) answered `high` and `max` with a 400 "Invalid inference request.", so Hermes, which sends the user's `max`, fell back to the user's other, paid provider. They now render `xhigh`, the template's highest level, and `minimal` renders `low`.
- MiMo V2.6 thinks for every effort but `none` (it refused them all), Nemotron 3.5 Super renders `minimal` and `low` at its medium depth and `xhigh` and `max` at its default (it refused them), and DiffusionGemma and Flint take `max`.
- An effort that is none of the names is refused on every model that reasons, also on Qwen 3.5 and 3.6, Bonsai 2, Gemma 4, GPT-OSS and Nemotron 3.5 Lightning, which rendered it. The local API answers 400 with code `invalid_reasoning_effort`, the field in `param`, and the accepted names. A model that doesn't reason ignores any effort.
- Nemotron 3.5 Super reads both `reasoning_effort` and `reasoning.effort`, and refuses two that differ, even two names such as `high` and `max`. Its local API now answers that with the same 400 as an unknown name (code `invalid_reasoning_effort`, `param` naming both fields, and the accepted names), where it gave an untyped "Invalid inference request." Send one of them, or the same effort in both.
90 changes: 77 additions & 13 deletions docs/architecture/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,7 @@ spends the caller's `max_tokens` before any JSON is written. A nested
`reasoning.enabled`, a raw `enable_thinking` or `chat_template_kwargs`
switch, any reasoning effort, or a positive `reasoning.max_tokens` budget
keeps the caller's choice. The family predicate also matches Qwen3.8
Flash-Next by model ID; `Qwen4SupportPolicy.validateReasoningContext` accepts
Flash-Next by model ID, whose template takes
the closed block. Other families keep their thinking defaults because the
predicate excludes them; GLM5-Next, MiMo and Nemotron Super also build their
own template context, and Flint's template ignores the switch.
Expand Down Expand Up @@ -2961,14 +2961,75 @@ and the coordinator can refuse to route

A template `raise_exception` at request time is classified `jinja_template`
and returned as HTTP 500, the provider-fault class, so a caller control that
a template is known to reject must be validated before rendering. The
Flash-Next and Qwen3.8-27B templates accept only `low`, `medium` and `xhigh`
while thinking is enabled; any other active effort, such as OpenAI's `high`
or `minimal`, is a typed HTTP 400 `client_error` and never reaches Jinja, on
text and media requests alike
(`provider-swift/Sources/ProviderCore/Inference/Qwen4SupportPolicy.swift`,
`validateReasoningContext`). Media preparation rethrows such typed request
errors instead of wrapping them as a retryable 503 construction refusal.
a template is known to reject must be resolved before rendering. The
Flash-Next and Qwen3.8-27B templates raise for any effort but `low`, `medium`
and `xhigh` while thinking; they receive one of those for every effort a
client sends ([reasoning effort](#reasoning-effort)), on text and media
requests alike. Media preparation rethrows typed request errors instead of
wrapping them as a retryable 503 construction refusal.

### Reasoning effort

Every model that reasons takes each effort a client names (`none`,
`minimal`, `low`, `medium`, `high`, `xhigh`, `max`) as `reasoning_effort` or
`reasoning.effort`; Responses' `reasoning.effort` arrives as the latter, which
wins over the top-level spelling (Nemotron 3.5 Super reads both, below). Its
template receives one of the model's own levels: its own where the model has
it, else the next one up (an effort between two levels rounds up, toward more
reasoning), and the highest past them all. So `minimal` selects the lowest
level and `max` the highest. `none` (also `off` or `0`) switches thinking off
where the model can, and selects the lowest level where it can't. Spellings
are trimmed and read in any case,
except by GLM-5.3-Flash and Flint, which read the names exactly as written.
Each family's table of the seven efforts is in one place,
`provider-swift/Sources/ProviderCore/Inference/Prompting/ReasoningEffort.swift`,
and `ReasoningEffortValuesTests` checks every row against this rule. One Mac,
a pair's leader (tensor parallel and pipeline) and the coordinator path render
through the same prompt pipeline; the local router returns this Mac's answer
as it is, or passes the request's body on unchanged.

| Family | Its levels | What each effort renders | Source |
|---|---|---|---|
| The Qwen 3.5 template family (`qwen3_5`, `qwen3_5_moe`, `prism_hadamard_qwen35`: Qwen 3.5, 3.6 and 3.8, Bonsai 2) and the owned Qwen 3.8 Flash-Next build | Qwen 3.8's `low`, `medium` and `xhigh` (its default), and a thinking switch | While thinking: `minimal` and `low` render `low`, `medium` renders `medium`, `high`, `xhigh` and `max` render `xhigh`, as the coordinator's first-party pool sends `high`. Thinking off: the effort as sent, which the template ignores. The 3.5, 3.6 and Bonsai templates read only the switch | `ReasoningEffort.qwen38Level`, `ReasoningEffortPolicy.templateEffort`, `Qwen4SupportPolicy.ownsEffortTemplate` |
| GLM-5.3-Flash | `low`, `high` and `max` (its default); thinking off closes `<think>` | `minimal` and `low` render `low`, `medium` and `high` render `high`, `xhigh` and `max` render `max`, as the platform sidecar maps them | `ReasoningEffort.glmLevel` (`GLM5NextPromptPolicy`) |
| Nemotron 3.5 Super | `medium_effort`, and the template's default depth | `minimal`, `low` and `medium` set `medium_effort`; `high`, `xhigh` and `max` keep the default | `ReasoningEffort.nemotronSuperMediumEffort` (`NemotronSuperPromptContract.controls(body:)`) |
| MiMo V2.6, DiffusionGemma | one depth, and a thinking switch | Every effort but `none` thinks | `ReasoningEffort.oneDepthThinking` (`MiMoV26TemplateFix`, `DiffusionGemmaReasoningControl`) |
| Gemma 4, Nemotron 3.5 Lightning | a thinking switch | `none` switches thinking off; any other effort keeps the template's default (Gemma 4: off) | `MultiModelBatchSchedulerEngine.templateAdditionalContext` |
| GPT-OSS | Harmony's `low`, `medium` and `high` | The effort as sent, except `high`, which renders `medium` | `GPTOSSHarmonyTemplateFix.effectiveReasoningEffort` |
| Flint | none: Flint decides whether to reason | Every effort is taken, with no effect | `FlintRequestPolicy` |

An effort that is none of the names is refused on any model that reasons,
with `MultiModelBatchSchedulerEngineError.unsupportedReasoningEffort(field)`
(HTTP 400), before the prompt renders or any KV is reserved. The engine
checks the effort once the request holds its model
(`MultiModelBatchSchedulerEngine.prepareCompletion`, after
`acquireForCompletion`; Super's owner in `NemotronSuperRequestPlan`), so a
cold model may load first, and on one Mac's unified endpoint the request
counts as the owner's use for "me first". The refusal releases the model.
MiMo's and Flint's efforts are checked before that when the model is
resident, and through the coordinator MiMo's, Flint's and GLM-5.3-Flash's are
refused before the request is accepted
(`ProviderPromptContractPipeline.nativeControlsRefusal`). The local API
answers `invalid_reasoning_effort` naming the field and the names ([direct
mode](../provider/direct-mode.md#reasoning-effort)); the coordinator receives
the closed `invalid_request` failure, which it shows as "invalid inference
request". A model of no family above ignores any effort
(`ReasoningEffortPolicy.validate`).

Nemotron 3.5 Super reads both fields rather than letting `reasoning.effort`
win, and refuses two that differ, even two names such as `high` and `max`,
with `conflictingReasoningEfforts` (HTTP 400) at the same point
(`NemotronSuperPromptContract.controls(body:)`). The local API answers it in
the same shape: code `invalid_reasoning_effort`, `param` naming both fields
(`"reasoning_effort, reasoning.effort"`), and a message naming both fields and
the names, never the values sent. Through the coordinator it is the same
closed `invalid_request`. The same effort in both fields, in any spelling, is
served.

Gemma 4 and GPT-OSS keep the prompts they rendered before: the coordinator's
prompt sidecar plans those prompts for cache-aware routing, so changing one
needs the sidecar's matching change and a new normalization version.
<!-- pending B-J2-1: Gemma 4 thinks for an effort other than none, and GPT-OSS renders each effort as its nearest Harmony level, once the platform's prompt sidecar renders them so. -->

### Vision constraints

Expand Down Expand Up @@ -3806,7 +3867,8 @@ evidence, not a change to the normal final-row contract or the near-tie rule
| Request cancelled by lease | No admission/prefill/decode progress within 120 s, or a step over 30 s. On the local API this comes after the response head, so a queued request that waits out the admission lease ends a streamed answer with an error event (as does a paged pool that stays full through its requeues) | `EngineLoopV2.swift`; `EngineV2Bridge+Events.swift` |
| `promptExceedsContext` (400) | The prompt alone fills the slot's window (its advertised context, else its model's); a larger output is cut, never refused | `provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+Submission.swift` (`submitTokenized`) |
| `advertisedContextExceeded` (400) | Candidate output reservation is negative or overflows; with the output cut to the window, nothing larger reaches it on one Mac | `provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+Submission.swift` (`submitTokenized`); `provider-swift/Sources/ProviderCore/ProviderLoop+ErrorMapping.swift` (`sanitizedInferenceFailure`) |
| `unsupportedReasoningEffort` (400) | Active effort outside `low`/`medium`/`xhigh` on a restricted-effort template (Flash-Next, Qwen3.8-27B) | `provider-swift/Sources/ProviderCore/Inference/Qwen4SupportPolicy.swift` (`validateReasoningContext`) |
| `unsupportedReasoningEffort` (400; on the local API `invalid_reasoning_effort`) | A model that reasons received an effort that is none of `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` ([reasoning effort](#reasoning-effort)) | `provider-swift/Sources/ProviderCore/Inference/Prompting/ReasoningEffort.swift` (`ReasoningEffortPolicy.validate`); `provider-swift/Sources/ProviderCore/Server/StandaloneServer+HTTP.swift` (`CORSResponder`) |
| `conflictingReasoningEfforts` (400; on the local API `invalid_reasoning_effort`, `param` naming both fields) | Nemotron 3.5 Super received `reasoning_effort` and `reasoning.effort` that differ ([reasoning effort](#reasoning-effort)) | `provider-swift/Sources/ProviderCore/Inference/Prompting/NemotronSuperPromptContract.swift` (`controls(body:)`); `provider-swift/Sources/ProviderCore/Server/NemotronSuperLocalImageHTTP.swift` (`SuperHTTPErrors.map`); `provider-swift/Sources/ProviderCore/Server/StandaloneServer+HTTP.swift` (`CORSResponder`) |
| Model dropped from advertised set | Unsupported `model_type` | `EngineV2SupportedModels.swift` |
| Model advertised, capacity quotes rejected with reason `template` | Scan-time render check failed (`template_render_ok = false`) | `TemplateRenderCheck.swift`, `provider-swift/Sources/ProviderCore/Coordinator/CapacityQuoteEngine.swift` (`reject(.template)`) |
| Image rejected | Over `MediaIngest` caps or over the N² tower budget | `MediaIngest.swift`, `VisionTowerBudget.swift` |
Expand Down Expand Up @@ -3909,9 +3971,11 @@ Flint always decides for itself whether to reason; it has no trained switch,
effort level or budget, and its pinned template reads none of these controls
([Recursive's serving guide](https://github.com/RecursiveSI/flint/blob/2a247be0c0aec895ccb0ac7ca92229ec6df37288/sglang/README.md)).
`FlintRequestPolicy` accepts `reasoning_effort` and `reasoning.effort` (none,
minimal, low, medium, high or xhigh), `reasoning.enabled`, `enable_thinking`
and `chat_template_kwargs.enable_thinking`/`thinking` with no effect on the
prompt. Malformed values, unknown efforts, `preserve_thinking`, other reasoning
minimal, low, medium, high, xhigh or max, exactly as written),
`reasoning.enabled`, `enable_thinking` and
`chat_template_kwargs.enable_thinking`/`thinking` with no effect on the
prompt. Malformed values, unknown efforts (`invalid_reasoning_effort`),
`preserve_thinking`, other reasoning
keys and media are refused. When a request sets `reasoning.exclude` true,
`include_reasoning` false or `reasoning.enabled` false, `NativeToolStreamRouter`
withholds the generated reasoning, so chat completions, the Responses API and
Expand Down
19 changes: 18 additions & 1 deletion docs/developer/test.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test Provider And Native Contracts

> Last updated: 2026-11-07
> Last updated: 2026-11-08

Run isolated Swift, native-resource, public-fixture and landing tests here.
Backend integration and cross-implementation qualification are platform-owned.
Expand Down Expand Up @@ -1306,6 +1306,23 @@ SHA-256 in the commit. A provider change to the rendered prompt, such as the
Qwen JSON `response_format` thinking default, lands with the regenerated
vectors and must pass `scripts/verify-prompt-parity.sh` before review.

`fixtures/prompt-contract/v1/native_reasoning_vectors.json` (28 cases) is this
repository's: the template context the provider gives each reasoning control,
or its refusal. `CachePromptParityTests` checks the provider against it, and
the platform's prompt sidecar and first-party pool read the same cases, so a
change lands here first and the platform follows. Since the reasoning-effort
levels ([reasoning effort](../architecture/inference.md#reasoning-effort)),
Qwen 3.8 Flash-Next's `high`, `max`, `minimal` and ` low ` render a level and
`turbo` is refused. `ReasoningEffortValuesTests` checks every family's table
against the rounding rule and sends every effort to every family through the
production prompt pipeline, and
`ReasoningEffortLocalAPITests` sends them to one Mac's local API and a pair
leader's over the `ClusterAPIParityTests` harness. It also renders Nemotron 3.5
Super's refusal of two efforts that differ through `SuperHTTPErrors` and
`CORSResponder`; `NemotronSuperLocalHTTPTests`' live text route sends it, and
an unknown `reasoning.effort`, through the real application (it needs Metal,
so it runs in CI).

darkbloom-platform keeps byte-identical copies of the provider's
`paged_footprint_wire.json` and `process_memory_wire.json` for its own
coordinator and console tests. Coordinate fixture changes with the platform and
Expand Down
Loading
Loading