Stream CLI stdout/stderr to stage logs during poll

Sync cli_stdout.log and cli_stderr.log to stage_dir each poll iteration
so there is visibility into what the CLI agent is doing before it finishes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-07 00:58:40 -05:00
parent 552e7d7636
commit 378c3eb3e3

View file

@ -384,6 +384,22 @@ impl CodergenBackend for AgentCliBackend {
.await
.map_err(|e| ArcError::handler(format!("Failed to poll CLI command: {e}")))?;
let status = poll_result.stdout.trim();
// Sync CLI output to stage_dir for visibility (best-effort)
for (remote, local) in [
(&stdout_path, "cli_stdout.log"),
(&stderr_path, "cli_stderr.log"),
] {
if let Ok(r) = sandbox
.exec_command(&format!("cat {remote}"), 30_000, None, None, None)
.await
{
if !r.stdout.is_empty() {
let _ = tokio::fs::write(stage_dir.join(local), &r.stdout).await;
}
}
}
if status != "running" {
break status.parse::<i32>().unwrap_or(-1);
}