mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-04 16:38:49 +00:00
chore(codex): identify failing request stage (#4929)
This commit is contained in:
parent
1a1e666625
commit
07f54c25e3
@ -75,10 +75,12 @@ class OpenAICodexProvider(LLMProvider):
|
|||||||
if tools:
|
if tools:
|
||||||
body["tools"] = convert_tools(tools)
|
body["tools"] = convert_tools(tools)
|
||||||
|
|
||||||
|
stage = "oauth_token"
|
||||||
try:
|
try:
|
||||||
token = await asyncio.to_thread(get_codex_token, proxy=self.proxy)
|
token = await asyncio.to_thread(get_codex_token, proxy=self.proxy)
|
||||||
headers = _build_headers(token.account_id, token.access)
|
headers = _build_headers(token.account_id, token.access)
|
||||||
|
|
||||||
|
stage = "codex_request"
|
||||||
try:
|
try:
|
||||||
content, tool_calls, finish_reason, usage, reasoning_content = await _request_codex(
|
content, tool_calls, finish_reason, usage, reasoning_content = await _request_codex(
|
||||||
DEFAULT_CODEX_URL, headers, body, verify=True,
|
DEFAULT_CODEX_URL, headers, body, verify=True,
|
||||||
@ -109,8 +111,9 @@ class OpenAICodexProvider(LLMProvider):
|
|||||||
response = _codex_error_response(e)
|
response = _codex_error_response(e)
|
||||||
exc_type = "CodexHTTPError" if isinstance(e, _CodexHTTPError) else type(e).__name__
|
exc_type = "CodexHTTPError" if isinstance(e, _CodexHTTPError) else type(e).__name__
|
||||||
logger.warning(
|
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={}",
|
"error_type={} error_code={} retry_after={} summary={}",
|
||||||
|
stage,
|
||||||
exc_type,
|
exc_type,
|
||||||
response.error_kind,
|
response.error_kind,
|
||||||
response.error_should_retry,
|
response.error_should_retry,
|
||||||
|
|||||||
@ -294,9 +294,10 @@ async def test_codex_timeout_error_writes_diagnostic_log(monkeypatch) -> None:
|
|||||||
)
|
)
|
||||||
assert log_capture.calls == [
|
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={}",
|
"error_type={} error_code={} retry_after={} summary={}",
|
||||||
(
|
(
|
||||||
|
"codex_request",
|
||||||
"ReadTimeout",
|
"ReadTimeout",
|
||||||
"timeout",
|
"timeout",
|
||||||
True,
|
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 response.content == "Error calling Codex (CodexHTTPError): HTTP 500: Codex API request failed"
|
||||||
assert log_capture.calls == [
|
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={}",
|
"error_type={} error_code={} retry_after={} summary={}",
|
||||||
(
|
(
|
||||||
|
"codex_request",
|
||||||
"CodexHTTPError",
|
"CodexHTTPError",
|
||||||
"http",
|
"http",
|
||||||
True,
|
True,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user