fix: a failed Codex turn shows a raw object as the error instead of Codex's message (#35385)

When Codex failed a turn, the reply's error showed Codex's whole error object, field names and all, instead of the reason. The error now shows Codex's own message, the same way Claude Code and Pi failures show theirs.

Fixes #35381
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-30 22:41:11 +04:00
1 parent 82ab95e420
commit 3d6a092c76
1 file changed
+2 -2
+2 -2
View File
@@ -173,7 +173,7 @@ async def run(transport, output, prompt, images, options):
if turn.get('id') != turn_id:
continue
if turn.get('status') == 'failed' or turn.get('error'):
raise ValueError(str(turn.get('error') or 'Codex turn failed'))
raise ValueError((turn.get('error') or {}).get('message') or 'Codex turn failed')
return
elif method == 'thread/tokenUsage/updated':
usage = (params.get('tokenUsage') or {}).get('last') or {}
@@ -187,7 +187,7 @@ async def run(transport, output, prompt, images, options):
if native in usage
}
elif method == 'error' and not params.get('willRetry'):
raise ValueError(str(params.get('error') or params))
raise ValueError((params.get('error') or {}).get('message') or str(params))
except asyncio.CancelledError:
if thread_id and turn_id:
with contextlib.suppress(Exception):