v0.10.5

推理等級

最後更新


llmrouter.Reasoning 六個等級如何對映到各家,以及模型無法支援時的處理。

等級


各等級對映到各家的不同機制:Claude 的 thinking budget(4.5/4.1)或 adaptive thinking effort(較新模型)、Gemini 的 thinking config、OpenAI 的 reasoning effort。
等級字串別名
ReasoningNonenone—
ReasoningLowlowminimal
ReasoningMediummedium(預設)—
ReasoningHighhigh—
ReasoningXHighxhighextra
ReasoningMaxmaxultra

收斂到模型範圍


超出模型支援範圍的請求不會被拒絕,而是收斂到最接近的合法值並輸出 debug log。實作 ReasoningAgent 的轉接層都已在 Send 內部收斂;自行呼叫 ClampReasoning 只是為了事先得知實際等級:
  1. if limited, ok := agent.(llmrouter.ReasoningAgent); ok {
  2. low, high := limited.ReasoningLimits()
  3. reasoning = llmrouter.ClampReasoning(reasoning, low, high, "openai", "gpt-5.1")
  4. }

deepseek、cloudflare、compat 忽略此等級;claude-code 以 effort 傳給 CLI,none 會以 low 送出。
收斂而非報錯的理由:呼叫端通常是一個對所有模型共用的設定值,讓上限比較低的模型直接跑完,比讓整個請求失敗更符合實際使用。

Claude 模型範圍


claude 依模型 ID 決定可用範圍與 none 的送法:
模型 ID 含範圍none 送出
-4-5、-4-1none–high(thinking budget)不開 thinking,temperature 0.2
opus-5low–max不會送出;none 收斂為 low
sonnet-5none–maxthinking: {"type": "between_tools"}
fable、mythosnone–max不帶 thinking 欄位
其他 IDnone–maxthinking: {"type": "disabled"}

相關頁面


EN