Skip to content
Python

Composer: a grouped model picker and settings for this session

Devika Verma053c4a0d97ba
diff --git a/coworker/server/app.py b/coworker/server/app.py
index da1e0fdb..d946d2b1 100644
--- a/coworker/server/app.py
+++ b/coworker/server/app.py
@@ -459,6 +459,14 @@ def create_app(manager: SessionManager) -> FastAPI:
value = body["attendance"] if "attendance" in body else bool(body.get("unattended"))
return manager.set_unattended(session_id, value)
+ @app.get("/v1/sessions/{session_id}/model-settings")
+ def session_model_settings(session_id: str) -> dict[str, Any]:
+ return manager.session_model_settings(session_id)
+
+ @app.post("/v1/sessions/{session_id}/model-settings")
+ def set_session_model_settings(session_id: str, body: dict) -> dict[str, Any]:
+ return manager.set_session_model_settings(session_id, body or {})
+
@app.get("/v1/sessions/{session_id}/skills")
def session_skills(session_id: str, workspace: str = "") -> dict[str, Any]:
# The rail's Skills group + the composer popup both read this (SKILLS-SPEC §4.1).
diff --git a/coworker/server/manager.py b/coworker/server/manager.py
index afbbf3af..89ec1e56 100644
--- a/coworker/server/manager.py
+++ b/coworker/server/manager.py
@@ -6145,6 +6145,59 @@ class SessionManager:
except Exception:
pass
+ def set_session_model_settings(self, session_id: str, values: dict[str, Any]) -> dict[str, Any]:
+ """This session's thinking switch or effort level (UX-055: the ⚙ beside the model
+ in the composer). Overrides the model's saved setting for this session only;
+ None puts the model's setting back. Other sessions are untouched."""
+ engine = self._engines.get(session_id)
+ if engine is None:
+ return {"ok": False, "error": "session not running"}
+ settings = dict(engine.model_settings)
+ if "reasoning_effort" in values:
+ effort = values["reasoning_effort"]
+ if effort is None:
+ settings.pop("reasoning_effort", None)
+ elif isinstance(effort, str) and effort.strip():
+ settings["reasoning_effort"] = effort.strip()
+ else:
+ return {"ok": False, "error": "reasoning_effort must be text"}
+ if "thinking" in values:
+ think = values["thinking"]
+ extra = dict(settings.get("extra_body") or {})
+ if think is None:
+ extra.pop("think", None)
+ elif isinstance(think, bool):
+ extra["think"] = think
+ else:
+ return {"ok": False, "error": "thinking must be true or false"}
+ if extra:
+ settings["extra_body"] = extra
+ else:
+ settings.pop("extra_body", None)
+ if "thinking" in values or "reasoning_effort" in values:
+ session_model = _model_config.model_settings_for(engine.model)
+ # Nothing overridden any more → back to the model's own settings.
+ if "reasoning_effort" not in settings and not (settings.get("extra_body") or {}).get("think") in (True, False):
+ for key in ("reasoning_effort",):
+ if key in session_model:
+ settings[key] = session_model[key]
+ if "extra_body" in session_model and "extra_body" not in settings:
+ settings["extra_body"] = session_model["extra_body"]
+ engine.model_settings = settings
+ return {"ok": True, "session_id": session_id, **self.session_model_settings(session_id)}
+
+ def session_model_settings(self, session_id: str) -> dict[str, Any]:
+ """What this session sends for thinking and effort right now."""
+ engine = self._engines.get(session_id)
+ if engine is None:
+ return {"thinking": None, "reasoning_effort": None}
+ settings = engine.model_settings or {}
+ think = (settings.get("extra_body") or {}).get("think")
+ return {
+ "thinking": think if isinstance(think, bool) else None,
+ "reasoning_effort": settings.get("reasoning_effort"),
+ }
+
def set_unattended(self, session_id: str, value: Any) -> dict[str, Any]:
"""Set the session's attendance (attended / inbox / auto, or the legacy boolean),
with an audit row. Note this changes only WHO ANSWERS when the agent asks, never
diff --git a/surfaces/gui/src/App.tsx b/surfaces/gui/src/App.tsx
index 4ed613dd..2d7a87ef 100644
--- a/surfaces/gui/src/App.tsx
+++ b/surfaces/gui/src/App.tsx
@@ -239,6 +239,8 @@ export function App() {
const [model, setModel] = useState("gpt-5.6-sol");
const [models, setModels] = useState<string[]>([]);
const [modelLabels, setModelLabels] = useState<Record<string, string>>({});
+ // Per-model settings the user saved (UX-055): the picker shows context and thinking.
+ const [modelConfig, setModelConfig] = useState<Record<string, import("./api").ModelConfigRecord>>({});
// {full model id → context window in tokens} from the curated matrix (verified only);
// drives the composer usage chip's context-fill meter.
const [modelContextWindows, setModelContextWindows] = useState<Record<string, number>>({});
@@ -786,6 +788,7 @@ export function App() {
.then((s) => {
setModels(s.models || []);
setModelLabels(s.model_labels || {});
+ setModelConfig(s.model_config || {});
setModelContextWindows(s.model_context_windows || {});
setContextBar(s.context_bar === true);
setModelReady(s.model_ready);
@@ -2434,6 +2437,12 @@ export function App() {
unavailableModels={unavailableModels}
wantedModels={personaModels}
modelLabels={machine ? machineSettings?.model_labels || {} : modelLabels}
+ modelConfig={machine ? machineSettings?.model_config || {} : modelConfig}
+ // "Pick or configure a model…" opens Models & Keys with the dialog up.
+ onPickModel={() => {
+ try { sessionStorage.setItem("ow:pick-model", "1"); } catch { /* private window */ }
+ openSettings("models");
+ }}
running={running}
gateOpen={!unattended && (!!pendingTeam || !!pendingItemsReq)}
// An offline machine's cached transcript is read-only: the send
diff --git a/surfaces/gui/src/api.ts b/surfaces/gui/src/api.ts
index 02ae6cb4..1c732ee3 100644
--- a/surfaces/gui/src/api.ts
+++ b/surfaces/gui/src/api.ts
@@ -2525,6 +2525,24 @@ export async function removeModelConfig(model: string): Promise<{ ok: boolean }>
return res.json();
}
+/** This session's thinking switch and effort level (UX-055, the ⚙ beside the model). */
+export async function getSessionModelSettings(sessionId: string): Promise<{ thinking: boolean | null; reasoning_effort: string | null }> {
+ const res = await fetch(`${httpBase()}/v1/sessions/${encodeURIComponent(sessionId)}/model-settings`);
+ return res.json();
+}
+
+export async function setSessionModelSettings(
+ sessionId: string,
+ values: { thinking?: boolean | null; reasoning_effort?: string | null },
+): Promise<{ ok: boolean; error?: string; thinking?: boolean | null; reasoning_effort?: string | null }> {
+ const res = await fetch(`${httpBase()}/v1/sessions/${encodeURIComponent(sessionId)}/model-settings`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(values),
+ });
+ return res.json();
+}
+
/** This machine, for the "Your system" section. */
export interface SystemFacts {
processor: string;
diff --git a/surfaces/gui/src/components/Composer.tsx b/surfaces/gui/src/components/Composer.tsx
index 75b1d0e2..2fa67e42 100644
--- a/surfaces/gui/src/components/Composer.tsx
+++ b/surfaces/gui/src/components/Composer.tsx
@@ -3,7 +3,7 @@ import { getI18n, useTranslation } from "react-i18next";
import type { Attachment, SessionUsage } from "../types";
import { isPdfFile, readFile } from "../attach";
import { ProjectBindMenu } from "./ProjectBindMenu";
-import { getSettings, inspectPdf, sessionSkills, type SessionSkillRow } from "../api";
+import { getSessionModelSettings, getSettings, inspectPdf, sessionSkills, setSessionModelSettings, type SessionSkillRow } from "../api";
import { formatTokens, totalTokens } from "../usage";
import { Dropdown, type Option } from "./Dropdown";
import { Icon } from "./Icon";
@@ -98,6 +98,10 @@ interface Props {
// names what would work instead of a bare warning.
wantedModels?: string[];
modelLabels?: Record<string, string>; // curated display names (raw id when absent)
+ // UX-055: saved per-model settings (context size, thinking) for the picker's notes,
+ // and the way into Models & Keys' Pick a model dialog.
+ modelConfig?: Record<string, { context_size?: number; thinking?: boolean }>;
+ onPickModel?: () => void;
// The model is FIXED once the session has history (§17): the picker renders ONLY on a fresh
// session; after the first turn the fact lives in the topbar subtitle (§22) — no
// interactive-then-disabled control.
@@ -508,15 +512,29 @@ export function Composer(props: Props) {
};
const modelsLoaded = !!(props.models && props.models.length);
+ // UX-055: the picker groups models by where they run and notes each one's saved
+ // context and thinking; the label drops the provider when it sits on the row's note.
+ const localPrefixes = ["ollama:", "llamacpp:", "vllm:"];
+ const isLocalModel = (m: string) => localPrefixes.some((p) => m.startsWith(p));
const modelOptions: Option[] = Array.from(
new Set([props.model, ...(props.models || [])]),
- ).map((m) => ({
- value: m,
- label: props.modelLabels?.[m] || shortModel(m),
- ...(props.unavailableModels?.includes(m)
- ? { description: t("onmachine.composer.model_unavailable") }
- : {}),
- }));
+ ).sort((a, b) => Number(isLocalModel(b)) - Number(isLocalModel(a))).map((m) => {
+ const full = props.modelLabels?.[m] || shortModel(m);
+ const [name, provider] = full.split(" · ");
+ const cfg = props.modelConfig?.[m];
+ const notes = isLocalModel(m)
+ ? [cfg?.context_size ? `${Math.round(cfg.context_size / 1024)}K` : "", cfg?.thinking ? t("composer.model.thinking") : ""]
+ : [provider || (m.includes(":") ? m.split(":")[0] : "")];
+ return {
+ value: m,
+ label: name,
+ group: t(isLocalModel(m) ? "composer.model.group_local" : "composer.model.group_cloud"),
+ meta: notes.filter(Boolean).join(" · "),
+ ...(props.unavailableModels?.includes(m)
+ ? { description: t("onmachine.composer.model_unavailable") }
+ : {}),
+ };
+ });
const iconBtn =
"w-7 h-7 grid place-items-center rounded-md text-faint hover:text-ink hover:bg-paper shrink-0";
@@ -797,6 +815,16 @@ export function Composer(props: Props) {
align="right"
displayLabel={modelName}
tooltip={modelTip}
+ searchFrom={6}
+ searchPlaceholder={t("composer.model.search")}
+ testId="model-picker"
+ footer={
+ props.onPickModel ? (
+ <button onClick={props.onPickModel} data-testid="model-picker-pick">
+ + {t("composer.model.pick_or_configure")}
+ </button>
+ ) : null
+ }
leading={
props.contextBar === true && hasUsage ? (
<ContextRing pct={ctxPct} label={ctxLine} testId="usage-chip" />
@@ -814,6 +842,10 @@ export function Composer(props: Props) {
</button>
))}
+ {!props.compact && modelsLoaded && props.sessionId && (
+ <SessionModelSettings sessionId={props.sessionId} model={props.model} local={isLocalModel(props.model)} onPickModel={props.onPickModel} />
+ )}
+
{/* mic — immediately before send (owner call, DMG #28 walkthrough) */}
{!props.compact && isTauri() && (
<button
@@ -1076,3 +1108,82 @@ function AttachChip({ a, onRemove }: { a: Attachment; onRemove: () => void }) {
</div>
);
}
+
+
+// UX-055: the ⚙ beside the model pill. This session's thinking switch (a local model)
+// or effort level (a cloud model), over the model's own setting; other sessions keep
+// theirs. The link at the bottom opens the model's defaults in Models & Keys.
+function SessionModelSettings({
+ sessionId,
+ model,
+ local,
+ onPickModel,
+}: {
+ sessionId: string;
+ model: string;
+ local: boolean;
+ onPickModel?: () => void;
+}) {
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+ const [state, setState] = useState<{ thinking: boolean | null; reasoning_effort: string | null } | null>(null);
+ useEffect(() => {
+ if (!open) return;
+ getSessionModelSettings(sessionId).then(setState).catch(() => setState({ thinking: null, reasoning_effort: null }));
+ }, [open, sessionId, model]);
+ const apply = (values: { thinking?: boolean | null; reasoning_effort?: string | null }) =>
+ setSessionModelSettings(sessionId, values).then((r) => {
+ if (r.ok) setState({ thinking: r.thinking ?? null, reasoning_effort: r.reasoning_effort ?? null });
+ });
+ const seg = (on: boolean, label: string, onClick: () => void) => (
+ <button className={"px-2.5 py-0.5 text-meta " + (on ? "bg-accent text-panel" : "text-muted hover:text-ink")} onClick={onClick}>
+ {label}
+ </button>
+ );
+ return (
+ <div className="relative shrink-0">
+ <button
+ className={"w-7 h-7 grid place-items-center rounded-md hover:bg-paper " + (open ? "text-accent" : "text-faint hover:text-ink")}
+ title={t("composer.model.session_settings")}
+ aria-label={t("composer.model.session_settings")}
+ onClick={() => setOpen((v) => !v)}
+ data-testid="session-model-settings"
+ >
+ ⚙
+ </button>
+ {open && (
+ <>
+ <div className="fixed inset-0 z-30" onClick={() => setOpen(false)} />
+ <div className="absolute z-40 bottom-full mb-1 right-0 w-[300px] rounded-xl border border-line bg-panel shadow-2xl p-3" data-testid="session-model-settings-menu">
+ <div className="text-label text-faint font-semibold tracking-wide uppercase mb-2">{t("composer.model.this_session")}</div>
+ {state && local && (
+ <div className="flex items-center text-ui">
+ {t("composer.model.thinking_label")}
+ <span className="ml-auto flex rounded-md border border-lineStrong overflow-hidden">
+ {seg(state.thinking === false, t("composer.model.off"), () => apply({ thinking: false }))}
+ {seg(state.thinking === true, t("composer.model.on"), () => apply({ thinking: true }))}
+ {seg(state.thinking === null, t("composer.model.models_setting"), () => apply({ thinking: null }))}
+ </span>
+ </div>
+ )}
+ {state && !local && (
+ <div className="flex items-center text-ui">
+ {t("composer.model.effort_label")}
+ <span className="ml-auto flex rounded-md border border-lineStrong overflow-hidden">
+ {(["low", "medium", "high"] as const).map((lvl) => seg(state.reasoning_effort === lvl, t(`composer.model.effort_${lvl}`), () => apply({ reasoning_effort: lvl })))}
+ {seg(state.reasoning_effort === null, t("composer.model.models_setting"), () => apply({ reasoning_effort: null }))}
+ </span>
+ </div>
+ )}
+ <p className="text-meta text-faint mt-2">{t("composer.model.session_only_note")}</p>
+ {onPickModel && (
+ <button className="mt-2 text-meta text-accent" onClick={() => { setOpen(false); onPickModel(); }}>
+ {t("composer.model.change_defaults")}
+ </button>
+ )}
+ </div>
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/surfaces/gui/src/components/Dropdown.tsx b/surfaces/gui/src/components/Dropdown.tsx
index dfb986e3..51d0c58f 100644
--- a/surfaces/gui/src/components/Dropdown.tsx
+++ b/surfaces/gui/src/components/Dropdown.tsx
@@ -5,6 +5,10 @@ export interface Option {
value: string;
label: string;
description?: string;
+ // UX-055: the menu groups options under these headings, in first-seen order.
+ group?: string;
+ // A short right-aligned note on the row (context size, provider).
+ meta?: string;
}
interface Props {
@@ -23,6 +27,12 @@ interface Props {
// Rich hover card rendered ABOVE the trigger after a short delay (replaces the native
// title, which is slow, bottom-anchored and unstyled). Hidden while the menu is open.
tooltip?: ReactNode;
+ // UX-055 (the model picker): a search box above the rows once there are this many
+ // options or more, and a footer row under them (e.g. "Pick or configure a model…").
+ searchFrom?: number;
+ searchPlaceholder?: string;
+ footer?: ReactNode;
+ testId?: string;
}
const TIP_DELAY_MS = 450;
@@ -38,9 +48,14 @@ export function Dropdown({
title,
leading,
tooltip,
+ searchFrom,
+ searchPlaceholder,
+ footer,
+ testId,
}: Props) {
const [open, setOpen] = useState(false);
const [tip, setTip] = useState(false);
+ const [query, setQuery] = useState("");
const timer = useRef<number | null>(null);
const armTip = () => {
if (!tooltip) return;
@@ -55,6 +70,31 @@ export function Dropdown({
useEffect(() => () => disarmTip(), []);
const current = options.find((o) => o.value === value);
const label = (prefix ? `${prefix}: ` : "") + (current?.label || value);
+ const q = query.trim().toLowerCase();
+ const shown = q ? options.filter((o) => o.label.toLowerCase().includes(q) || o.value.toLowerCase().includes(q)) : options;
+ const groups = Array.from(new Set(shown.map((o) => o.group || "")));
+ const showSearch = searchFrom !== undefined && options.length >= searchFrom;
+ const row = (o: Option) => (
+ <div
+ key={o.value}
+ className={"dd-item" + (o.value === value ? " sel" : "")}
+ onClick={() => {
+ onChange(o.value);
+ setOpen(false);
+ setQuery("");
+ }}
+ data-testid={testId ? `${testId}-option-${o.value}` : undefined}
+ >
+ <div className="dd-label">
+ <span className="truncate">{o.label}</span>
+ <span className="flex items-center gap-2 shrink-0 ml-3">
+ {o.meta && <span className="dd-meta">{o.meta}</span>}
+ {o.value === value && <span className="chk">✓</span>}
+ </span>
+ </div>
+ {o.description && <div className="dd-desc">{o.description}</div>}
+ </div>
+ );
return (
<div className="dd" onMouseEnter={armTip} onMouseLeave={disarmTip}>
{tip && !open && tooltip && (
@@ -79,23 +119,26 @@ export function Dropdown({
{open && (
<>
<div className="dd-backdrop" onClick={() => setOpen(false)} />
- <div className={"dd-menu " + align}>
- {options.map((o) => (
- <div
- key={o.value}
- className={"dd-item" + (o.value === value ? " sel" : "")}
- onClick={() => {
- onChange(o.value);
- setOpen(false);
- }}
- >
- <div className="dd-label">
- {o.label}
- {o.value === value && <span className="chk">✓</span>}
+ <div className={"dd-menu " + align} data-testid={testId ? `${testId}-menu` : undefined}>
+ {showSearch && (
+ <input
+ className="dd-search"
+ autoFocus
+ placeholder={searchPlaceholder}
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ data-testid={testId ? `${testId}-search` : undefined}
+ />
+ )}
+ <div className="dd-rows">
+ {groups.map((g) => (
+ <div key={g || "_"}>
+ {g && <div className="dd-group">{g}</div>}
+ {shown.filter((o) => (o.group || "") === g).map(row)}
</div>
- {o.description && <div className="dd-desc">{o.description}</div>}
- </div>
- ))}
+ ))}
+ </div>
+ {footer && <div className="dd-footer">{footer}</div>}
</div>
</>
)}
diff --git a/surfaces/gui/src/components/ManageTabs.tsx b/surfaces/gui/src/components/ManageTabs.tsx
index 37d35e5d..8f05bb18 100644
--- a/surfaces/gui/src/components/ManageTabs.tsx
+++ b/surfaces/gui/src/components/ManageTabs.tsx
@@ -70,6 +70,13 @@ export function ModelsTab() {
const ps = useProviderSetup({ onSaved: refreshSettings });
useEffect(() => {
refreshSettings();
+ // The composer's "Pick or configure a model…" lands here with the dialog up.
+ try {
+ if (sessionStorage.getItem("ow:pick-model") === "1") {
+ sessionStorage.removeItem("ow:pick-model");
+ setDialog("+");
+ }
+ } catch { /* private window */ }
}, []);
if (!settings) return <div className="text-ui text-muted">{t("manage.loading")}</div>;
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index 1f2156c1..db9ff6ed 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -179,7 +179,24 @@
"none": "No model",
"none_aria": "No model connected — connect a model",
"loading": "Loading models…",
- "loading_title": "Fetching the model list from the server"
+ "loading_title": "Fetching the model list from the server",
+ "group_local": "On this computer",
+ "group_cloud": "Cloud",
+ "thinking": "thinking",
+ "search": "Search models…",
+ "pick_or_configure": "Pick or configure a model…",
+ "session_settings": "Settings for this session",
+ "this_session": "This session",
+ "thinking_label": "Thinking",
+ "effort_label": "Effort",
+ "on": "On",
+ "off": "Off",
+ "models_setting": "Default",
+ "effort_low": "Low",
+ "effort_medium": "Medium",
+ "effort_high": "High",
+ "session_only_note": "Other sessions keep the model's own setting.",
+ "change_defaults": "Change the model's defaults…"
},
"placeholder_gate": "Reply to adjust the proposal — or use the buttons above",
"attach_this_message": "This message",
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index 52cc6a57..1b017f39 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -177,7 +177,24 @@
"none": "无模型",
"none_aria": "未连接模型 —— 请先连接一个模型",
"loading": "正在加载模型…",
- "loading_title": "正在从服务器获取模型列表"
+ "loading_title": "正在从服务器获取模型列表",
+ "group_local": "在这台电脑上",
+ "group_cloud": "云端",
+ "thinking": "思考",
+ "search": "搜索模型…",
+ "pick_or_configure": "选择或配置模型…",
+ "session_settings": "此会话的设置",
+ "this_session": "此会话",
+ "thinking_label": "思考",
+ "effort_label": "推理强度",
+ "on": "开",
+ "off": "关",
+ "models_setting": "默认",
+ "effort_low": "低",
+ "effort_medium": "中",
+ "effort_high": "高",
+ "session_only_note": "其他会话保持模型自身的设置。",
+ "change_defaults": "更改模型的默认设置…"
},
"placeholder_gate": "回复以调整提案 —— 或使用上方按钮",
"attach_this_message": "本条消息",
diff --git a/surfaces/gui/src/styles.css b/surfaces/gui/src/styles.css
index 9017efb3..e2d8ff06 100644
--- a/surfaces/gui/src/styles.css
+++ b/surfaces/gui/src/styles.css
@@ -668,6 +668,13 @@ button.btn.danger { color: var(--accent); }
.dd-label { font-size: var(--fs-ui); color: var(--ink); display: flex; justify-content: space-between; align-items: center; }
.dd-item .chk { color: var(--accent); }
.dd-desc { font-size: var(--fs-meta); color: var(--faint); margin-top: 1px; }
+.dd-meta { font-size: var(--fs-meta); color: var(--faint); }
+.dd-group { font-size: var(--fs-label); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px; }
+.dd-rows { max-height: 320px; overflow: auto; }
+.dd-search { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 2px 0 6px; font-size: var(--fs-ui); background: var(--panel); color: var(--ink); outline: none; }
+.dd-footer { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
+.dd-footer button { width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px; font-size: var(--fs-ui); color: var(--accent); background: transparent; border: 0; cursor: pointer; }
+.dd-footer button:hover { background: var(--paper); }
.send { width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--accent); color: #fff; cursor: pointer; font-size: 16px; }
.send:disabled { opacity: 0.4; cursor: default; }
.statusline { max-width: 760px; margin: 6px auto 0; font-size: var(--fs-meta); color: var(--faint); display: flex; gap: 12px; }
diff --git a/tests/test_model_config.py b/tests/test_model_config.py
index 8d46746f..d96a5562 100644
--- a/tests/test_model_config.py
+++ b/tests/test_model_config.py
@@ -228,3 +228,25 @@ def test_only_tool_capable_ollama_models_join_the_picker(tmp_path, monkeypatch):
])
mgr = SessionManager(data_dir=tmp_path)
assert mgr._ollama_models() == ["ollama:qwen3-coder:30b", "ollama:old-server-model"]
+
+
+def test_a_session_can_switch_thinking_and_effort_for_itself(tmp_path):
+ from types import SimpleNamespace
+
+ from coworker.server.manager import SessionManager
+
+ mgr = SessionManager(data_dir=tmp_path)
+ engine = SimpleNamespace(model="ollama:nemotron-3.5-lightning:30b", model_settings={"max_tokens": 16000, "extra_body": {"think": True}})
+ mgr._engines["s1"] = engine
+ assert mgr.session_model_settings("s1") == {"thinking": True, "reasoning_effort": None}
+ out = mgr.set_session_model_settings("s1", {"thinking": False})
+ assert out["ok"] and engine.model_settings["extra_body"] == {"think": False}
+ assert engine.model_settings["max_tokens"] == 16000 # the rest stays
+ out = mgr.set_session_model_settings("s1", {"reasoning_effort": "high"})
+ assert out["reasoning_effort"] == "high"
+ # Back to the model's own settings.
+ mgr.set_session_model_settings("s1", {"thinking": None, "reasoning_effort": None})
+ assert engine.model_settings.get("extra_body") == {"think": True}
+ assert "reasoning_effort" not in engine.model_settings
+ assert mgr.set_session_model_settings("nope", {"thinking": True}) == {"ok": False, "error": "session not running"}
+ assert mgr.set_session_model_settings("s1", {"thinking": "yes"})["ok"] is False