DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(llm): stop matching bare 'tool' in schema-fallback detector
ZQR1101ee7cbd7b5218
diff --git a/deeptutor/services/llm/request_compat.py b/deeptutor/services/llm/request_compat.pyindex 2080518cd..5a68a451a 100644--- a/deeptutor/services/llm/request_compat.py+++ b/deeptutor/services/llm/request_compat.py@@ -76,12 +76,18 @@ def is_stream_options_unsupported(exc: Exception) -> bool:def is_tool_schema_unsupported(exc: Exception) -> bool:- """Whether a provider rejected native tool/function-calling schemas."""+ """Whether a provider rejected native tool/function-calling schemas.++ Deliberately avoids matching the bare substring ``\"tool\"``. Any 400 that+ merely mentions tools — or echoes the outbound request body — used to trip+ the chat loop's silent strip-and-retry path and leave the model answering+ in prose with no tools (#708). Keep markers tied to schema/parameter+ rejections; ``logged_error_text`` already captures unknowns for follow-up.+ """text = error_text(exc)return any(marker in textfor marker in (- "tool","function_declaration","function declaration","function_declarations",@@ -89,6 +95,18 @@ def is_tool_schema_unsupported(exc: Exception) -> bool:"parameters.properties","404_not_found","404 not_found",+ "unsupported parameter: tools",+ "unknown parameter: tools",+ "unknown parameter 'tools'",+ 'unknown parameter "tools"',+ "unexpected keyword argument 'tools'",+ "tools is not supported",+ "tools are not supported",+ "does not support tools",+ "does not support function calling",+ "function calling is not supported",+ "tool use is not supported",+ "tool calling is not supported",))diff --git a/tests/services/llm/test_request_compat.py b/tests/services/llm/test_request_compat.pyindex d3b9a707e..091b5d2a5 100644--- a/tests/services/llm/test_request_compat.py+++ b/tests/services/llm/test_request_compat.py@@ -28,6 +28,8 @@ def test_error_text_prefers_provider_response_body() -> None:def test_request_compatibility_classifiers_match_known_provider_errors() -> None:assert is_stream_options_unsupported(ValueError("unknown parameter: stream_options"))assert 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_image_input_unsupported(ValueError("content must be a string"))@@ -39,6 +41,17 @@ def test_request_compatibility_classifiers_ignore_unrelated_errors() -> None:assert not is_image_input_unsupported(error)+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]"+ )+ 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"))++def test_transient_transport_classifier_walks_wrapped_causes() -> None:try:try: