fix(models): raise ContextWindowOverflowException for ollama/llama/mistral/writer#2958
fix(models): raise ContextWindowOverflowException for ollama/llama/mistral/writer#2958gautamsirdeshmukh wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| - System prompts | ||
| """ | ||
|
|
||
| OVERFLOW_MESSAGES = { |
There was a problem hiding this comment.
Issue (verification): The substring matching is the crux of this fix — if these strings don't match what the provider actually returns, the except branch becomes silent dead code and the bug persists undetected. The unit tests assert against these same hardcoded strings, so they'd pass even if the strings are wrong.
Suggestion: Confirm these strings against real provider error text (an integ test that intentionally overflows the context, or a captured real error in the PR description). Worth noting where each string came from, since several read like reasonable guesses (e.g. "input too large", "too many tokens").
| "model's maximum context limit", | ||
| "is longer than the model's context length", | ||
| "prompt is too long", | ||
| "too many tokens", |
There was a problem hiding this comment.
Issue: This OVERFLOW_MESSAGES set is byte-for-byte identical to the one added in llamaapi.py. Two copies of the same substring list will drift over time as one provider's error strings are tuned and the other is forgotten.
Suggestion: If LlamaAPI and Writer genuinely share the same OpenAI-compatible error vocabulary, consider hoisting the shared strings to a single module-level constant (mirroring how bedrock.py and openai.py keep these lists as module constants) rather than duplicating per class.
|
Assessment: Comment Solid, well-targeted fix that follows the established provider pattern (Anthropic's Review themes
Nice work extending the recovery path to four more providers — the Ollama lazy-iteration handling in particular is a thoughtful touch. |
Description
Related Issues
Documentation PR
Type of Change
Bug fix
New feature
Breaking change
Documentation update
Other (please describe):
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.