fix: retry without reasoning_effort on Ollama's "does not support thinking" error (#20) - #32
Open
vishnujayvel wants to merge 1 commit into
Open
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #20 — local Ollama users hit a hard failure when
reasoning_effortis seton a model that doesn't support thinking (e.g.
llama3.2).Why
OpenPlanter already recovers when a provider rejects
reasoning_effort: itcatches the error, drops the parameter, and re-sends once. But that recovery only
fired when the error text contained the substring
reasoning_effort(OpenAI'sphrasing). Ollama's OpenAI-compat shim rejects reasoning on non-thinking models
with a message like
"llama3.2" does not support thinking, which never mentionsreasoning_effortat all — so the retry never triggered and the request justfailed.
What changed
agent/model.py— broaden the retry-without-reasoning condition to also match"thinking"+"does not support"errors. The original OpenAI-style clause ispreserved (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_effortand the retry drops it.Verification
python -m pytest tests/test_model.py— 8/8 pass.agent/model.pychange makes the new testfail with the uncaught
ModelError; restored after.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 futureprovider'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.