Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
chore(codex): identify failing request stage (#4929)
chengyongru07f54c25e345
diff --git a/nanobot/providers/openai_codex_provider.py b/nanobot/providers/openai_codex_provider.pyindex a89e3cac6..1db8fa798 100644--- a/nanobot/providers/openai_codex_provider.py+++ b/nanobot/providers/openai_codex_provider.py@@ -75,10 +75,12 @@ class OpenAICodexProvider(LLMProvider):if tools:body["tools"] = convert_tools(tools)+ stage = "oauth_token"try:token = await asyncio.to_thread(get_codex_token, proxy=self.proxy)headers = _build_headers(token.account_id, token.access)+ stage = "codex_request"try:content, tool_calls, finish_reason, usage, reasoning_content = await _request_codex(DEFAULT_CODEX_URL, headers, body, verify=True,@@ -109,8 +111,9 @@ class OpenAICodexProvider(LLMProvider):response = _codex_error_response(e)exc_type = "CodexHTTPError" if isinstance(e, _CodexHTTPError) else type(e).__name__logger.warning(- "Codex API request failed: type={} kind={} retryable={} status={} "+ "Codex API request failed: stage={} type={} kind={} retryable={} status={} ""error_type={} error_code={} retry_after={} summary={}",+ stage,exc_type,response.error_kind,response.error_should_retry,diff --git a/tests/providers/test_openai_codex_provider.py b/tests/providers/test_openai_codex_provider.pyindex 560b25e7b..6c80ba615 100644--- a/tests/providers/test_openai_codex_provider.py+++ b/tests/providers/test_openai_codex_provider.py@@ -294,9 +294,10 @@ async def test_codex_timeout_error_writes_diagnostic_log(monkeypatch) -> None:)assert log_capture.calls == [(- "Codex API request failed: type={} kind={} retryable={} status={} "+ "Codex API request failed: stage={} type={} kind={} retryable={} status={} ""error_type={} error_code={} retry_after={} summary={}",(+ "codex_request","ReadTimeout","timeout",True,@@ -414,9 +415,10 @@ async def test_codex_http_diagnostic_log_omits_raw_body(monkeypatch) -> None:assert response.content == "Error calling Codex (CodexHTTPError): HTTP 500: Codex API request failed"assert log_capture.calls == [(- "Codex API request failed: type={} kind={} retryable={} status={} "+ "Codex API request failed: stage={} type={} kind={} retryable={} status={} ""error_type={} error_code={} retry_after={} summary={}",(+ "codex_request","CodexHTTPError","http",True,