Skip to content

fix: retry without reasoning_effort on Ollama's "does not support thinking" error (#20) - #32

Open
vishnujayvel wants to merge 1 commit into
ShinMegamiBoson:mainfrom
vishnujayvel:fix/20-ollama-thinking-retry
Open

fix: retry without reasoning_effort on Ollama's "does not support thinking" error (#20)#32
vishnujayvel wants to merge 1 commit into
ShinMegamiBoson:mainfrom
vishnujayvel:fix/20-ollama-thinking-retry

Conversation

@vishnujayvel

Copy link
Copy Markdown

What

Fixes #20 — local Ollama users hit a hard failure when reasoning_effort is set
on a model that doesn't support thinking (e.g. llama3.2).

Why

OpenPlanter already recovers when a provider rejects reasoning_effort: it
catches the error, drops the parameter, and re-sends once. But that recovery only
fired when the error text contained the substring reasoning_effort (OpenAI's
phrasing). Ollama's OpenAI-compat shim rejects reasoning on non-thinking models
with a message like "llama3.2" does not support thinking, which never mentions
reasoning_effort at all — so the retry never triggered and the request just
failed.

What changed

  • agent/model.py — broaden the retry-without-reasoning condition to also match
    "thinking" + "does not support" errors. The original OpenAI-style clause is
    preserved (OR'd on), so providers that already worked behave identically.
    Still effort-gated and single-shot: a genuine, unrelated error still propagates.
  • tests/test_model.py — regression test using the exact Local ollama error: llama3.2 does not support thinking #20 error string,
    asserting the first call sends reasoning_effort and the retry drops it.

Verification

  • python -m pytest tests/test_model.py8/8 pass.
  • revert-confirms-fail: removing the agent/model.py change makes the new test
    fail with the uncaught ModelError; restored after.
  • Verified against a unit mock of Ollama's error shape — there is no live-Ollama
    e2e in the suite, so the fix keys on the documented error string.

Honest note

This remains string-matching on unstructured provider errors (Ollama sends
param: null, code: null, so there's nothing structured to key on) — a future
provider's phrasing could miss again. This PR widens the net for the reported
case; it doesn't replace the approach.

Thanks to the #20 reporter for the exact error string.

…nking" error

Ollama's OpenAI-compat shim rejects reasoning_effort on models that
don't support it (e.g. llama3.2) with a message like `"llama3.2" does
not support thinking`, which never mentions `reasoning_effort` at all.
The existing retry-without-reasoning_effort check required
"reasoning_effort" in the error text, so it never fired for ollama and
the request just failed.

Broaden the match to also catch "thinking" + "does not support" style
errors, and add a regression test using the exact ollama error shape
from ShinMegamiBoson#20.

Fixes ShinMegamiBoson#20
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.

Local ollama error: llama3.2 does not support thinking

1 participant