Skip to content

drop the reasoning effort when an Ollama agent model cannot think - #6130

Merged
atomantic merged 1 commit into
mainfrom
cos/sys-mtm2sq93/agent-77346cc5
Sep 3, 2026
Merged

drop the reasoning effort when an Ollama agent model cannot think#6130
atomantic merged 1 commit into
mainfrom
cos/sys-mtm2sq93/agent-77346cc5

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

  • A CoS agent dispatched at effort: medium onto a non-reasoning Ollama model died on its first turn with Error: "gemma3:27b" does not support thinking, exit 1, no output. A pr-reviewer Stage 2 run hit this three times and blocked its task.
  • Ollama rejects the whole request rather than ignoring a reasoning field the model has no answer for — both natively (think: true on /api/chat) and through the OpenAI-compatible reasoning_effort that OpenCode's agent.*.reasoningEffort becomes.
  • New dropUnsupportedOllamaThinking() in server/services/ollamaAgentContext.js resolves the model's capability once per spawn, on the provider every spawn path shares (TUI / runner / direct), so the two carriers of the level — the --effort argv and OpenCode's config block — drop it together.
  • Unknown stays unknown: a failed /api/show probe or an empty capability list leaves the level alone, and a provider pointed at a remote daemon is never probed (ollamaManager only inspects the local one). Mirrors modelRejectsThinking in codeReview.js, which already solves this for the local reviewer's own HTTP calls.

Test plan

  • server/services/ollamaAgentContext.test.js — 8 new cases: drops effort and a thinking: true override for a capability-less model, keeps them for a thinking-capable one, keeps them on null/[] capabilities, and never probes at all for a no-thinking run, a non-Ollama provider, or a remote daemon.
  • Verified against the live local daemon: reasoning_effort and think: true both return "gemma3:27b" does not support thinking; the same requests without them return 200.
  • npx vitest run (server workspace): 38675 passed. One unrelated services/sprites/atlas.test.js timeout under full-suite load; passes in isolation.

Ollama rejects the whole request — `"<model>" does not support thinking` —
rather than ignoring a reasoning field a model has no answer for, both on
native /api/chat (`think: true`) and through the OpenAI-compatible
`reasoning_effort` that OpenCode's `agent.*.reasoningEffort` becomes. So an
agent dispatched at `effort: medium` onto a non-reasoning local model died on
its first turn with exit 1 and no output: a pr-reviewer Stage 2 run pinned to
gemma3:27b (capabilities ["completion","vision"]) failed three times that way
and blocked its task.

Resolve the model's thinking capability once per spawn, on the provider every
spawn path shares, so the two carriers of the level — the `--effort` argv and
OpenCode's config block — drop it together. A failed /api/show probe or an
empty capability list means *unknown*, not *unsupported*, and leaves the level
alone; a provider pointed at a remote daemon is never probed, since
ollamaManager only inspects the local one. Mirrors modelRejectsThinking in
codeReview.js, which already solves this for the local reviewer's own calls.
@atomantic
atomantic merged commit 7c7a886 into main Sep 3, 2026
7 checks passed
@atomantic
atomantic deleted the cos/sys-mtm2sq93/agent-77346cc5 branch September 3, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant