agent: a thinking level in agent.yaml and per call
ci / check (push) Successful in 9m11s

- thinking (off, low, medium, high, xhigh, max) is an enum: serde rejects
  unknown levels in the config, and the schema of agent.chat lists them.
  reasoning_effort, a second name for the same setting, is gone.
- agent.chat takes an optional thinking level for one turn.
- off really switches thinking off: OpenAI gets the effort none, and
  Anthropic gets disabled thinking (newer Claude models think by
  default). A model that cannot switch thinking off gets low.
- Unset means the model's default. Anthropic thinking blocks now return
  unless thinking is off, because newer models think by default.
- The template sets thinking: medium and shows it in each example, with
  current model names.
- Checked against the proxy with gpt-6-luna, glm-5.3-flash, and
  claude-haiku-5-5.
This commit is contained in:
2026-10-23 13:01:36 +01:00
parent b536beb069
commit 895be183c9
5 changed files with 166 additions and 53 deletions
+7 -2
View File
@@ -4,7 +4,7 @@ mod llm;
mod tools;
use history::{is_too_large, next_turn_start};
use llm::{Config, Entry};
use llm::{Config, Entry, Thinking};
use sausage_plugin::{Ctx, Error, Result, lock, rpc, schema};
use serde_json::json;
use std::io::Write;
@@ -22,6 +22,10 @@ struct Agent;
struct ChatParams {
/// The complete text of the person's request.
text: String,
/// The thinking level of this turn only. Without it, the turn uses `thinking` from
/// `/config/agent.yaml`.
#[serde(default, skip_serializing_if = "Option::is_none")]
thinking: Option<Thinking>,
}
#[rpc(grace_seconds = 600)]
@@ -32,7 +36,8 @@ impl Agent {
async fn chat(&self, ctx: &Ctx, p: ChatParams) -> Result<String> {
let _guard = lock(HISTORY).await?;
std::fs::create_dir_all("/state/agent")?;
let cfg = Config::load().map_err(|error| Error::new(-32603, error))?;
let mut cfg = Config::load().map_err(|error| Error::new(-32603, error))?;
cfg.thinking = p.thinking.or(cfg.thinking);
let mut entries = load_history(HISTORY)?;
repair_tools(&mut entries)?;
let current = entries.len();