Skip to content

The agent that grows with you

test(error_classifier): cover Qwen applyPromptTemplate vs llama.cpp grammar

xxxigm847cc47cdbfb
diff --git a/tests/agent/test_error_classifier.py b/tests/agent/test_error_classifier.py
index 37b498b251c..d2e5a194216 100644
--- a/tests/agent/test_error_classifier.py
+++ b/tests/agent/test_error_classifier.py
@@ -483,9 +483,55 @@ class TestClassifyApiError:
# ── Provider-specific: llama.cpp grammar-parse ──
+ def test_llama_cpp_unable_to_generate_parser_template(self):
+ e = MockAPIError(
+ "Unable to generate parser for this template. "
+ "Automatic parser generation failed: error parsing grammar",
+ status_code=400,
+ )
+ result = classify_api_error(e, provider="custom", model="local-llama")
+ assert result.reason == FailoverReason.llama_cpp_grammar_pattern
+ assert result.retryable is True
+ assert result.should_compress is False
+ def test_qwen_apply_prompt_template_no_user_query_not_llama_cpp_grammar(self):
+ """Local engines wrap Qwen raise_exception as applyPromptTemplate 400.
+ Must NOT classify as llama_cpp_grammar_pattern (which strips tool
+ schema keywords and retries). Fail fast as format_error so the user
+ sees a request-shape failure instead of a misleading template/parser
+ loop — typical after context overflow + failed compression.
+ """
+ e = MockAPIError(
+ "Engine protocol applyPromptTemplate request returned 400: "
+ '{"error":{"code":400,"message":"Unable to generate parser for '
+ "this template. Automatic parser generation failed: "
+ "While executing CallExpression ... multi_step_tool %} "
+ "{{- raise_exception('No user query found in messages')",
+ status_code=400,
+ )
+ result = classify_api_error(
+ e,
+ provider="custom",
+ model="qwen/qwen3.6-35b-a3b",
+ approx_tokens=226_000,
+ context_length=100_864,
+ )
+ assert result.reason == FailoverReason.format_error
+ assert result.retryable is False
+ assert result.should_compress is False
+ assert result.should_fallback is True
+ def test_bare_no_user_query_found_is_format_error_even_on_large_session(self):
+ e = MockAPIError("No user query found in messages", status_code=400)
+ result = classify_api_error(
+ e,
+ approx_tokens=226_000,
+ context_length=100_864,
+ )
+ assert result.reason == FailoverReason.format_error
+ assert result.retryable is False
+ assert result.should_compress is False
# ── Provider-specific: Anthropic long-context tier ──