feat: forward reasoning_effort to the backend so jinja models honor it#10184
Merged
Conversation
reasoning_effort was only mapped to the binary enable_thinking toggle and otherwise reached Go-side templates — it was never sent to the backend. So jinja-templated models whose chat template keys on reasoning_effort (gpt-oss Harmony, LFM2.5) could not be driven by it: LFM2.5 ignores enable_thinking and kept emitting <think>. Forward the effective reasoning_effort to the backend as a chat_template_kwarg (mirroring enable_thinking) in grpc-server.cpp, and put it in PredictOptions metadata (gRPCPredictOpts). Add a config-level default: ModelConfig.reasoning_effort and Pipeline.reasoning_effort, resolved by ModelConfig.ApplyReasoningEffort (request value overrides config default, none->disable / level->enable, an operator's reasoning.disable wins). request.go now uses that helper. Assisted-by: Claude:claude-opus-4-8 go test, golangci-lint Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Apply Pipeline.ReasoningEffort to the pipeline's LLM config when the realtime model is built (per-session copy, overrides the LLM's own reasoning_effort), and surface the resolved effort on the template input so Go-templated models get it too. jinja models receive it via the backend metadata. This lets a realtime pipeline disable thinking on models that only honor reasoning_effort (e.g. LFM2.5), which enable_thinking can't. Assisted-by: Claude:claude-opus-4-8 go test, golangci-lint Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
mudler
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
reasoning_effortwas only mapped to the binaryenable_thinkingtoggle and otherwise reached Go-side templates — it was never forwarded to the backend. So jinja-templated models whose chat template keys onreasoning_effort(gpt-oss / Harmony, LFM2.5) could not be driven by it. In particular LFM2.5 ignoresenable_thinkingand keeps emitting<think>, but honorsreasoning_effort.This PR forwards the effective
reasoning_effortto the backend as achat_template_kwarg(mirroring howenable_thinkingis already forwarded), and adds a config-level default so it can be pinned per model / per realtime pipeline.Changes
grpc-server.cpp): forwardmetadata["reasoning_effort"]→body_json["chat_template_kwargs"]["reasoning_effort"]in both the streaming and non-streaming predict paths, next toenable_thinking.options.go): put the effectivereasoning_effortintoPredictOptions.Metadata.ModelConfig.reasoning_effort(model default) andPipeline.reasoning_effort(realtime), resolved byModelConfig.ApplyReasoningEffort— a per-request value overrides the config default;none→disable, level→enable, and an operator'sreasoning.disable: truestill wins.request.gonow uses that shared helper (no behavior change for the existing per-request path).Pipeline.ReasoningEffortto the pipeline's LLM (per-session copy) and surface it on the template input.Test plan
ApplyReasoningEffortunit tests (request>config precedence, none/level mapping, operator-disable wins).gRPCPredictOptsforwardsreasoning_effortinto metadata (and omits when empty).request.gorefactor — middleware tests green.applyPipelineReasoningtest.reasoning_effort: nonesuppresses<think>(C++ path — verifies on CI build / live).Assisted-by: Claude:claude-opus-4-8 go test, golangci-lint
🤖 Generated with Claude Code