Hmbown/CodeWhale · error
Cloud agent harness exited with code
Error message
Cloud agent harness exited with code {exit_code}: {} What it means
Thrown by `run_harness` when the harness command executed successfully at the HTTP level but its process exited with a non-zero exit code. The sandbox's `result` text is sanitized and appended to the message, so the message contains the harness's own failure output. This means the agent's command genuinely failed inside the sandbox, not that the transport broke.
Solutions
- Read the sanitized `result` text appended to the message — it names the actual command failure; fix the command or script it reports.
- Reproduce the command locally or in a fresh sandbox to see if it depends on uncommitted local state.
- If the exit code is 124/137 (timeout/kill), reduce the work per command or raise timeout_secs in the HarnessCommand.
- If a required binary is missing, update the sandbox base image or install it in the setup harness step.
Example fix
// before
HarnessCommand { argv: vec!["make", "release"], cwd: SANDBOX_WORKSPACE.into(), timeout_secs: 60 }
// after (tool missing / too slow in sandbox)
HarnessCommand { argv: vec!["bash", "-lc", "cargo build --release"], cwd: SANDBOX_WORKSPACE.into(), timeout_secs: 600 } Defensive patterns
Strategy: try-catch
Validate before calling
// surface the sanitized result text to the user before deciding to retry
let msg = err.to_string();
let detail = msg.splitn(2, ": ").nth(1).unwrap_or(""); Try / catch
match result {
Err(e) if e.to_string().contains("exited with code") => {
log_harness_failure(&e.to_string()); // includes sanitized sandbox output
// do not blind-retry: the command itself failed
}
other => other,
} Prevention
- Install all toolchain dependencies in the sandbox base image before running harness commands.
- Set realistic timeout_secs per command; 124/137 exit codes mean timeout/killed.
- Reproduce commands locally to catch sandbox/local environment drift.
- Always read the sanitized output appended to the message — it names the real failure.
When it happens
Trigger: Any harness command (setup script, build, patch-extraction git commands) whose shell process exits non-zero: missing tool in the sandbox image, failing tests, git conflicts, script bugs, or out-of-memory kills (exit 137).
Common situations: Base image lacking a dependency the script assumes; repository state differing from local (rebuilt from remote head); command timeout producing a killed-process exit code; agent-authored shell commands with typos.
Related errors
- Command failed with exit code
- Cloud agent harness execution failed
- Cloud agent repository clone failed
- Cloud agent sandbox disappeared before it was ready.
- Cloud agent sandbox entered state
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/d3728fb96cd8e9bd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/cloud_dispatch.rs:1678
body,
)?;
let status = response.status();
let text = response.text().unwrap_or_default();
if !status.is_success() {
bail!("Cloud agent harness execution failed (HTTP {status}).");
}
let parsed: serde_json::Value = serde_json::from_str(&text)
.context("the sandbox returned an unreadable harness result")?;
let exit_code = parsed
.get("exitCode")
.and_then(serde_json::Value::as_i64)
.unwrap_or(0);
let result = parsed
.get("result")
.and_then(serde_json::Value::as_str)
.unwrap_or("");
if exit_code != 0 {
bail!(
"Cloud agent harness exited with code {exit_code}: {}",
sanitize_error(result)
);
}
Ok(result.chars().take(MAX_HARNESS_OUTPUT_CHARS).collect())
}
fn collect_patch(&self, receipt: &SandboxReceipt) -> Result<PatchReceipt> {
let base_branch = self
.run_harness(
receipt,
&HarnessCommand {
argv: vec![
"git".to_string(),
"rev-parse".to_string(),
"--abbrev-ref".to_string(),
"origin/HEAD".to_string(),
],View on GitHub (pinned to 73e0f67d83)