修复 Codex CLI 失败状态采集竞态
Project CI / Frontend tests (pull_request) Successful in 2m46s
Project CI / Repository checks (pull_request) Successful in 3m49s
Project CI / Backend tests (pull_request) Successful in 9m22s
Project CI / Native shell tests (pull_request) Successful in 21m52s

BrokenPipe 时继续采集子进程退出状态
保留 stderr 脱敏摘要并避免泄露原始错误
This commit is contained in:
2026-09-03 16:47:30 +08:00
parent d5e05d79fe
commit 1982756c6d
@@ -666,12 +666,27 @@ async fn request_game_creator_agent_codex_cli_with_executable(
let mut stdin = child.stdin.take().ok_or_else(|| {
platform_llm::LlmError::Transport("Codex CLI Agent stdin 未建立".to_string())
})?;
stdin.write_all(prompt.as_bytes()).await.map_err(|error| {
platform_llm::LlmError::Transport(format!("写入 Codex CLI Agent prompt 失败:{error}"))
})?;
stdin.shutdown().await.map_err(|error| {
platform_llm::LlmError::Transport(format!("关闭 Codex CLI Agent stdin 失败:{error}"))
})?;
// 短生命周期 CLI 可能在 prompt 写完前退出;继续采集退出状态和脱敏
// stderr,确保调用方拿到可行动的进程错误,而不是平台相关的 BrokenPipe。
let mut stdin_error = None;
if let Err(error) = stdin.write_all(prompt.as_bytes()).await {
if error.kind() == std::io::ErrorKind::BrokenPipe {
stdin_error = Some(format!("写入 Codex CLI Agent prompt 失败:{error}"));
} else {
return Err(platform_llm::LlmError::Transport(format!(
"写入 Codex CLI Agent prompt 失败:{error}"
)));
}
}
if let Err(error) = stdin.shutdown().await {
if error.kind() == std::io::ErrorKind::BrokenPipe {
stdin_error.get_or_insert_with(|| format!("关闭 Codex CLI Agent stdin 失败:{error}"));
} else {
return Err(platform_llm::LlmError::Transport(format!(
"关闭 Codex CLI Agent stdin 失败:{error}"
)));
}
}
drop(stdin);
let stdout = child.stdout.take().ok_or_else(|| {
@@ -744,6 +759,9 @@ async fn request_game_creator_agent_codex_cli_with_executable(
stderr.sha256
)));
}
if let Some(error) = stdin_error {
return Err(platform_llm::LlmError::Transport(error));
}
parse_game_creator_codex_cli_response(&stdout, &request)
}