DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(codex): fail closed on TLS verification errors
nox19e90e7529ef
diff --git a/deeptutor/services/llm/provider_core/openai_codex_provider.py b/deeptutor/services/llm/provider_core/openai_codex_provider.pyindex 13daefd80..7b0a81461 100644--- a/deeptutor/services/llm/provider_core/openai_codex_provider.py+++ b/deeptutor/services/llm/provider_core/openai_codex_provider.py@@ -99,19 +99,6 @@ class OpenAICodexProvider(LLMProvider):"Codex login expired and could not be renewed. Sign in again.",) from Noneraise- except Exception as exc:- if "CERTIFICATE_VERIFY_FAILED" not in str(exc):- raise- logger.warning(- "SSL verification failed for Codex API; retrying with verify=False"- )- content, tool_calls, finish_reason = await _request_codex(- CODEX_RESPONSES_URL,- headers,- body,- verify=False,- on_content_delta=on_content_delta,- )return LLMResponse(content=content,tool_calls=tool_calls,diff --git a/tests/services/llm/test_codex_disable_ssl_verify.py b/tests/services/llm/test_codex_disable_ssl_verify.pyindex 6f65e94f7..beeda5fa5 100644--- a/tests/services/llm/test_codex_disable_ssl_verify.py+++ b/tests/services/llm/test_codex_disable_ssl_verify.py@@ -1,9 +1,7 @@"""DISABLE_SSL_VERIFY coverage for the OpenAI Codex Responses provider.-The codex provider was previously hardcoded to ``verify=True`` on the first-attempt, with an auto-retry on ``CERTIFICATE_VERIFY_FAILED``. The flag now-short-circuits the first attempt while preserving the retry-on-cert-failure-fallback.+The flag controls the initial request. A certificate verification failure must+never trigger an automatic retry with verification disabled."""from __future__ import annotations@@ -11,9 +9,11 @@ from __future__ import annotationsfrom contextlib import asynccontextmanagerfrom typing import Any+import httpximport pytestfrom deeptutor.services.llm import openai_http_client+from deeptutor.services.llm.exceptions import LLMProviderTransportErrorfrom deeptutor.services.llm.provider_core import openai_codex_provider@@ -98,25 +98,21 @@ async def test_codex_first_attempt_verify_false_when_flag_set(@pytest.mark.asyncio-async def test_codex_retry_on_cert_failure_still_works(monkeypatch: pytest.MonkeyPatch) -> None:- """The CERTIFICATE_VERIFY_FAILED retry fallback is preserved."""+async def test_codex_certificate_failure_never_retries_without_verification(+ monkeypatch: pytest.MonkeyPatch,+) -> None:_stub_token_loader(monkeypatch)captured: list[dict[str, Any]] = []- call_count = {"n": 0}async def fake_request(*args: Any, **kwargs: Any) -> tuple[str, list[Any], str]:captured.append(kwargs)- call_count["n"] += 1- if call_count["n"] == 1:- raise RuntimeError("[SSL: CERTIFICATE_VERIFY_FAILED] cert chain")- return ("recovered", [], "stop")+ raise httpx.ConnectError("[SSL: CERTIFICATE_VERIFY_FAILED] cert chain")monkeypatch.setattr(openai_codex_provider, "_request_codex", fake_request)provider = openai_codex_provider.OpenAICodexProvider()- result = await provider.chat(messages=[{"role": "user", "content": "hi"}])+ with pytest.raises(LLMProviderTransportError):+ await provider.chat(messages=[{"role": "user", "content": "hi"}])- assert result.content == "recovered"- assert len(captured) == 2+ assert len(captured) == 1assert captured[0]["verify"] is True- assert captured[1]["verify"] is False