diff --git a/agent/error_classifier.py b/agent/error_classifier.py index 3489c66c949b1..84438e087ab23 100644 --- a/agent/error_classifier.py +++ b/agent/error_classifier.py @@ -661,7 +661,8 @@ def _result(reason: FailoverReason, **overrides) -> ClassifiedError: if ( status_code == 400 and ( - "error parsing grammar" in error_msg + "failed to parse grammar" in error_msg + or "error parsing grammar" in error_msg or "json-schema-to-grammar" in error_msg or ( "unable to generate parser" in error_msg diff --git a/tests/agent/test_error_classifier.py b/tests/agent/test_error_classifier.py index 6c533089986ce..6f36f441e1a6f 100644 --- a/tests/agent/test_error_classifier.py +++ b/tests/agent/test_error_classifier.py @@ -857,6 +857,17 @@ def test_llama_cpp_grammar_parse_error(self): assert result.retryable is True assert result.should_compress is False + def test_llama_cpp_failed_to_parse_grammar(self): + """Newer llama.cpp builds return 'Failed to initialize samplers: failed to parse grammar'.""" + e = MockAPIError( + "Failed to initialize samplers: failed to parse grammar", + status_code=400, + ) + result = classify_api_error(e, provider="openai-compatible") + assert result.reason == FailoverReason.llama_cpp_grammar_pattern + assert result.retryable is True + assert result.should_compress is False + def test_llama_cpp_unable_to_generate_parser(self): """Older llama.cpp builds surface the error as 'unable to generate parser'.""" e = MockAPIError(