Table of Contents
Reasoning Effort
Some models let a request say how much to reason before answering. Raif exposes this as a provider-neutral level: :none, :minimal, :low, :medium, :high, or :xhigh. Each model accepts only some of these levels, and Raif never rounds a level to the nearest one the model accepts.
When nothing sets a level, Raif sends no reasoning field, so the provider’s default applies. Requests are unchanged until you set one.
Supported models
The manifest declares the levels each model accepts, as reasoning_effort_levels. So far only Google’s Gemini 4 models declare levels, from Google’s thinking guide, checked 2026-12-02:
| Model key | Levels | Google’s default |
|---|---|---|
google_gemini_4_carbon | :low, :medium, :high | medium |
google_gemini_4_argon | :low, :medium, :high | medium |
google_gemini_4_neon | :low, :medium, :high, :xhigh | high |
google_gemini_4_hydrogen | :low, :medium, :high, :xhigh | high |
Raif sends the level as generationConfig.thinkingConfig.thinkingLevel. Other models, including the OpenRouter Gemini keys, declare no levels and accept none. Raif::Llm#reasoning_effort_levels and #accepts_reasoning_effort?(level) tell you what a model accepts.
A model registered with Raif.register_llm can declare levels in capabilities: { reasoning_effort_levels: [...] }, but only on an adapter that sends them (Raif::Llms::Google today). Registration raises otherwise, so a completion never records a level its request did not carry.
Setting a level
A level can come from three places. The first one that gives a level wins:
- The
reasoning_effort:argument toRaif::Llm#chator#build_pending_model_completion. - The task, conversation, or agent class’s
llm_reasoning_effortdeclaration. Raif.config.llm_reasoning_effort_defaults, keyed by model key.
Levels and model keys may be strings or symbols in declarations, host defaults, and chat arguments. A lambda receives the model key as a Symbol.
Host default
# config/initializers/raif.rb
Raif.config.llm_reasoning_effort_defaults = { google_gemini_4_carbon: :low }
This applies to every task, conversation, agent, and chat call on that model that does not set a level of its own. Raif checks it at boot, even when no LLM provider is enabled: an unknown model key or a level the model does not accept raises Raif::Errors::InvalidConfigError. A key for a model whose provider is not enabled on this machine is allowed.
Per class
llm_reasoning_effort is available on Raif::Task, Raif::Conversation, and Raif::Agent subclasses:
class Raif::Tasks::Summarize < Raif::ApplicationTask
# Every model that accepts :low
llm_reasoning_effort :low
# Or only named models
llm_reasoning_effort google_gemini_4_carbon: :low, google_gemini_4_hydrogen: :high
# Or both: the named entry wins for its model, :low applies to the rest
llm_reasoning_effort :low, google_gemini_4_hydrogen: :high
end
A subclass’s declaration replaces its parent’s, and llm_reasoning_effort nil clears an inherited one.
The two forms handle a model that does not accept the level differently:
- The level for every model is skipped on a model that does not accept it. Raif logs one warning per class and model key, and the host default applies instead, if there is one. One declaration can therefore cover a set of models from different providers.
- A named model’s level is strict. Raif checks each named entry the first time the class resolves a level, on any model. A key that is neither registered nor in the manifest, or a level that model does not accept, raises
ArgumentError. A key for a model whose provider is not enabled on this machine is allowed, so a class that names a Google model still runs on other providers there.
Per run
For a level that changes from run to run, declare a lambda. It receives the model key as a Symbol (for example :google_gemini_4_carbon) and is evaluated on the task, conversation, or agent instance, so it can read that instance’s state:
class Raif::Tasks::Forecast < Raif::ApplicationTask
run_with :reasoning_effort
llm_reasoning_effort ->(_model_key) { reasoning_effort }
end
Raif::Tasks::Forecast.run(creator: user, llm_model_key: "google_gemini_4_carbon", reasoning_effort: :low)
A lambda that returns nil falls through to the host default. A level it returns that the model does not accept raises, the same as a named entry.
Per call
Raif.llm(:google_gemini_4_carbon).chat(message: "Hello", reasoning_effort: :high)
Errors
A level the model does not accept, from a chat argument, a named entry, a lambda, or the host default, raises ArgumentError before Raif creates the Raif::ModelCompletion or sends a request, including when llm_api_requests_enabled is false. Error handling is otherwise unchanged:
Raif::Llm#chat,Raif::Task#run,Raif::Task#prepare_for_batch!, andRaif::Agent#run!raise to the caller.Raif::Task.runreturns the task, failed and with no completion, and reports the error throughRails.error.- A conversation turn marks the entry failed and returns
nil.
:none is a level, not an absence: it asks the provider to turn reasoning off, and only models that list it accept it. nil means “no level from this source”.
Batches
A batched task’s level is resolved when the completion is prepared and saved on it as request_settings["reasoning_effort"]. Submitting the batch later sends that saved level, so a host default added after preparation does not change it. Raif::Task#refresh_pending_model_completion! resolves the level again, including any host default added since preparation, so call it before submit_batch! if the task’s level or the host default changed.
Latency
A lower level is not a reliable way to speed up a search-heavy request. In one run on 2026-11-16, on Gemini 4 Carbon at :low with Google Search enabled, the request took 1,081 seconds and ended with TOO_MANY_TOOL_CALLS.
Smoke checks
bin/smoke <selectors> --only reasoning_effort sends one request per declared level and shows each level’s verdict. Models without levels report SKIP. It is opt-in and never recorded, because an accepted request shows the provider took the level, not that it honored it.