Repository navigation
fix(ollama): declare ResponseError as fallback-eligible so the structured-output ladder can switch strategies - #3615
Closed
konlue wants to merge 1 commit into
Conversation
…ured-output ladder can switch strategies
Contributor
|
Thanks for the pull request. One thing worth sorting out before it is reviewed:
If you think it belongs here anyway, say so and a maintainer will take a look. |
2 tasks done
Contributor
Author
|
Withdrawing — see #3614: the premise does not hold for Ollama (the strategies send byte-identical payloads, so a fallback cannot recover). Thanks for the automated check. |
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.
AgentScope Version
2.0.12dev (main @
4acacb9)Description
OllamaChatModelis the only mainline provider that does not override_get_structured_output_fallback_exceptions(base returns()). In the structured-output strategy ladder (model/_base.py:565-594), an exception that is neither retryable nor fallback-eligible raises immediately — so for Ollama, any server-side rejection (ollama.ResponseError, which the SDK uses for every non-transport failure including 4xx) kills the whole ladder on the first attempt, and theauto/no_think/nonestrategies are never tried.Changes — declare the fallback exception, verbatim provider style:
The retryable set (three httpx transport errors) stays untouched — transport failures keep retrying, protocol-level rejections now switch strategies. Same series as #3583/#3588 (Ollama thinking toggle) and #3612/#3613 (Gemini 4xx fall-through).
How to test
Regression cases added to the existing
tests/model_ollama_test.py:test_fallback_exceptions_declare_response_error— fails onmain(() != (ResponseError,));test_response_error_walks_the_ladder— records every_call_apiattempt while the ladder degrades: onmaina mockedResponseErrordies after1attempt; with this fix all four strategies are tried (4 attempts).python -m pytest tests/model_ollama_test.py # 15 passed.Fixes #3614
Checklist