Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion agent/error_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/agent/test_error_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down