fix(agent): classify OpenAI regex lookaround schema rejection as recoverable - #42635
fix(agent): classify OpenAI regex lookaround schema rejection as recoverable#42635liuhao1024 wants to merge 1 commit into
Conversation
…verable Some OpenAI-compatible endpoints (e.g. strict GPT tool-schema validation) reject tool schemas containing regex lookaround patterns in `pattern` keywords with HTTP 400 and the message: "Invalid JSON schema: regex lookaround is not supported." Previously this was classified as a non-retryable client error, causing the conversation to fail permanently. Route through the existing `strip_pattern_and_format()` recovery path (same as llama.cpp grammar errors) so Hermes strips the incompatible `pattern`/`format` keywords from tool schemas and retries once. Fixes NousResearch#42631
|
Thanks for the focused compatibility recovery. Current The focused classifier tests are appropriate for the new recognition branch, and the existing recovery path preserves its no-op/fall-through guard when no compatible schema keyword exists to strip. Automated hermes-sweeper review. |
|
We're pulling #67349 into our fork for a related llama.cpp/LM Studio grammar-phrase gap (same |
What does this PR do?
Classifies HTTP 400 errors from OpenAI-compatible endpoints that reject tool schemas containing regex lookaround patterns as recoverable, routing them through the existing
strip_pattern_and_format()retry path so the conversation continues instead of failing permanently.Related Issue
Fixes #42631
Type of Change
Changes Made
agent/error_classifier.py: Extended the llama.cpp grammar-pattern condition to also match OpenAI-compatible "regex lookaround is not supported" errors, routing them through the sameFailoverReason.llama_cpp_grammar_patternrecovery pathtests/agent/test_error_classifier.py: Added 2 tests — one verifying the lookaround error is classified as retryable, one verifying partial keyword matches don't trigger false positivesHow to Test
pytest tests/agent/test_error_classifier.py -q— all 157 tests pass (including the 2 new ones)pytest tests/tools/test_schema_sanitizer.py -q— all 40 schema sanitizer tests pass (verifies the downstream recovery path)test_openai_regex_lookaround_rejectiontest verifies the exact error message from the issue is classified asFailoverReason.llama_cpp_grammar_patternwithretryable=TrueChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
agent/error_classifier.py(error classification logic),agent/conversation_loop.py:2304(recovery path consumer),tools/schema_sanitizer.py:308(strip_pattern_and_format)llama_cpp_grammar_patternrecovery path at lines 606-621; this extends the same condition with an additional disjunct