fix codex.py wsl run err

This commit is contained in:
cexll
2025-11-13 15:41:54 +08:00
parent ed604f6db7
commit 7f61437eea

View File

@@ -155,7 +155,7 @@ def main():
# 等待进程结束 # 等待进程结束
returncode = process.wait(timeout=timeout_sec) returncode = process.wait(timeout=timeout_sec)
if returncode == 0: # 优先检查是否有有效输出,而非退出码
if last_agent_message: if last_agent_message:
# 输出 agent_message # 输出 agent_message
sys.stdout.write(f"{last_agent_message}\n") sys.stdout.write(f"{last_agent_message}\n")
@@ -164,13 +164,15 @@ def main():
if thread_id: if thread_id:
sys.stdout.write(f"\n---\nSESSION_ID: {thread_id}\n") sys.stdout.write(f"\n---\nSESSION_ID: {thread_id}\n")
# 有输出但退出码非零,输出警告而非失败
if returncode != 0:
log_warn(f'Codex completed with non-zero status {returncode} but produced valid output')
sys.exit(0) sys.exit(0)
else: else:
log_error('Codex completed without agent_message output') # 没有输出才算真正失败
sys.exit(1) log_error(f'Codex exited with status {returncode} without agent_message output')
else: sys.exit(returncode if returncode != 0 else 1)
log_error(f'Codex exited with status {returncode}')
sys.exit(returncode)
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
log_error('Codex execution timeout') log_error('Codex execution timeout')