DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(llm): require schema context for 404 fallback
Bingxi Zhao (Frank)6d596df19d6d
diff --git a/deeptutor/services/llm/request_compat.py b/deeptutor/services/llm/request_compat.pyindex 5a68a451a..5eb30d7f4 100644--- a/deeptutor/services/llm/request_compat.py+++ b/deeptutor/services/llm/request_compat.py@@ -85,7 +85,7 @@ def is_tool_schema_unsupported(exc: Exception) -> bool:rejections; ``logged_error_text`` already captures unknowns for follow-up."""text = error_text(exc)- return any(+ rejected_schema = any(marker in textfor marker in ("function_declaration",@@ -93,8 +93,6 @@ def is_tool_schema_unsupported(exc: Exception) -> bool:"function_declarations","tool_choice","parameters.properties",- "404_not_found",- "404 not_found","unsupported parameter: tools","unknown parameter: tools","unknown parameter 'tools'",@@ -109,6 +107,21 @@ def is_tool_schema_unsupported(exc: Exception) -> bool:"tool calling is not supported",))+ if rejected_schema:+ return True+ not_found = "404_not_found" in text or "404 not_found" in text+ return not_found and any(+ marker in text+ for marker in (+ "tool schema",+ "function schema",+ "function declaration",+ "function_declaration",+ "function calling",+ "tool calling",+ "tool_choice",+ )+ )def is_image_input_unsupported(exc: Exception) -> bool:diff --git a/tests/services/llm/test_request_compat.py b/tests/services/llm/test_request_compat.pyindex 091b5d2a5..4ecf28580 100644--- a/tests/services/llm/test_request_compat.py+++ b/tests/services/llm/test_request_compat.py@@ -30,6 +30,9 @@ def test_request_compatibility_classifiers_match_known_provider_errors() -> Noneassert is_tool_schema_unsupported(ValueError("function_declaration is unsupported"))assert is_tool_schema_unsupported(ValueError("unsupported parameter: tools"))assert is_tool_schema_unsupported(ValueError("unknown parameter: tools"))+ assert is_tool_schema_unsupported(+ ValueError("404_NOT_FOUND: function schema endpoint is unavailable")+ )assert is_image_input_unsupported(ValueError("content must be a string"))@@ -44,12 +47,13 @@ def test_request_compatibility_classifiers_ignore_unrelated_errors() -> None:def test_tool_schema_classifier_ignores_errors_that_only_mention_tool() -> None:"""Bare ``tool`` must not strip schemas — that silently disabled tools (#708)."""# A temperature / max_tokens rejection that happens to echo the tools list.- echoed = ValueError(- "unsupported parameter: temperature. request included tools=[web_search]"- )+ echoed = ValueError("unsupported parameter: temperature. request included tools=[web_search]")assert not is_tool_schema_unsupported(echoed)assert not is_tool_schema_unsupported(RuntimeError("tool call timed out"))assert not is_tool_schema_unsupported(ValueError("failed while invoking tool web_search"))+ assert not is_tool_schema_unsupported(+ ValueError("404_NOT_FOUND: model endpoint /v1/models/missing was not found")+ )def test_transient_transport_classifier_walks_wrapped_causes() -> None: