nikivdev/code · error
Agent exited with status: {}
Error message
Agent exited with status: {} What it means
After building the full prompt and dispatching to the chosen backend (Claude Code, gen, etc.), run_agent checks the child process exit status. A non-zero status means the agent backend ran but failed, so run_agent bails with 'Agent exited with status: <status>'. The message carries only the exit code, not the backend's output.
Source
Thrown at src/agents.rs:909
println!("Invoking {} agent...\n", agent);
let (tool, model) = get_agent_config();
let status = match tool.as_str() {
"claude" => invoke_claude(&full_prompt)?,
"opencode" => invoke_opencode(&full_prompt, model.as_deref())?,
_ => {
let gen_loc = find_gen().ok_or_else(|| {
anyhow::anyhow!(
"gen not found. Install with:\n cd {} && f install\n # or set GEN_REPO env var",
gen_repo_hint()
)
})?;
invoke_gen(&gen_loc, &full_prompt)?
}
};
if !status.success() {
bail!("Agent exited with status: {}", status);
}
Ok(())
}
/// Invoke Claude Code with a prompt.
fn invoke_claude(prompt: &str) -> Result<std::process::ExitStatus> {
Command::new("claude")
.args(["-p", prompt])
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.context("failed to run claude")
}
/// Invoke opencode with a prompt and optional model.
fn invoke_opencode(prompt: &str, model: Option<&str>) -> Result<std::process::ExitStatus> {View on GitHub (pinned to a747e741ae)
Solutions
- Re-run the agent command directly (e.g. `claude ...` or `gen ...`) to see its stderr/stdout.
- Authenticate the backend: run its login flow or set the required API key env var (e.g. ANTHROPIC_API_KEY).
- Verify the backend binary is installed and up to date.
- Retry with a smaller/simpler prompt if the backend crashed on input size.
Example fix
// before $ f agents run claude "review" Error: Agent exited with status: exit status: 1 // after $ claude --version && claude login # fix backend auth/install $ f agents run claude "review" # now succeeds
Defensive patterns
Strategy: retry
Validate before calling
command -v claude >/dev/null && claude --version >/dev/null 2>&1 \ && f agents run claude "prompt" || echo "backend agent not ready"
Type guard
fn backend_ready(cmd: &str) -> bool {
std::process::Command::new(cmd).arg("--version").output()
.map(|o| o.status.success()).unwrap_or(false)
} Try / catch
match run_agent(agent, prompt) {
Err(e) if e.to_string().starts_with("Agent exited with status") => {
eprintln!("Backend '{agent}' failed; run it directly for details.");
// optionally retry after fixing auth/install
}
other => other?,
} Prevention
- Authenticate backend CLIs (login flows, API key env vars) before use.
- Verify the backend binary is installed and current.
- For flaky/network backends, retry with backoff.
- Check backend logs by running the underlying command directly on failure.
When it happens
Trigger: The invoked agent backend (claude, gen, or a custom binary) exits non-zero — e.g. auth failure, missing API key, crashed model CLI, or the prompt caused a fatal backend error.
Common situations: Expired or missing API credentials for the backend agent CLI; backend not installed despite the name resolving; network failure reaching the model provider; backend OOM/crash on a large prompt.
Related errors
- Lin.app is not running
- gen exited with status: {}
- {} exited with {}
- Claude review failed
- kimi review failed: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/064bb05d4ea2b4f8.
Report an issue: GitHub.