{"record":{"id":"3ef5b4c1db624d65","repo":"nikivdev/code","slug":"hive-agent-exited-with-status","errorCode":null,"errorMessage":"hive agent '{}' exited with status {:?}","messagePattern":"hive agent '(.+?)' exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hive.rs","lineNumber":325,"sourceCode":"/// Run a hive agent with a prompt\npub fn run_agent(agent: &str, prompt: &str) -> Result<()> {\n    // Check if hive is available\n    if which::which(\"hive\").is_err() {\n        anyhow::bail!(\"hive not found on PATH. Install from https://github.com/example/hive\");\n    }\n\n    let status = Command::new(\"hive\")\n        .arg(\"agent\")\n        .arg(agent)\n        .arg(prompt)\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .context(\"Failed to run hive\")?;\n\n    if !status.success() {\n        anyhow::bail!(\n            \"hive agent '{}' exited with status {:?}\",\n            agent,\n            status.code()\n        );\n    }\n\n    Ok(())\n}\n\n/// Run an agent interactively (prompt via stdin)\npub fn run_agent_interactive(agent: &str) -> Result<()> {\n    if which::which(\"hive\").is_err() {\n        anyhow::bail!(\"hive not found on PATH\");\n    }\n\n    let status = Command::new(\"hive\")\n        .arg(\"agent\")\n        .arg(agent)","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/hive.rs#L307-L343","documentation":"`run_agent` spawns `hive agent <agent> <prompt>` with inherited stdio and waits via `.status()`. If the hive process exits with a failure code, the function bails with this message naming the agent and the exit status (as `Option<i32>` via `{:?}`). The actual reason for failure must come from hive's own output, which was streamed to the terminal.","triggerScenarios":"hive exiting non-zero for an unknown agent name, invalid prompt, its own internal error, or being killed by a signal (in which case `status.code()` is `None`, printed as `None`).","commonSituations":"Passing an agent name that has no corresponding hive agent definition; hive failing authentication or hitting an API rate limit; prompt rejected by hive; process killed by OOM-killer or Ctrl-C resulting in a signal exit.","solutions":["Check the hive output printed above the error (stdio is inherited) for the real cause","Verify the agent name exists: `hive agent <name>` or list available agents","Run the exact command manually to reproduce: `hive agent <agent> \"<prompt>\"`","If the status shows `None`, the process died by signal — check dmesg/limits (OOM) or rerun"],"exampleFix":"// before\nhive::run_agent(\"reviwer\", \"do the thing\")?; // typo'd agent\n// after\nlet agent = \"reviewer\"; // exact, existing agent name\nmatch hive::run_agent(agent, \"do the thing\") {\n    Err(e) => { eprintln!(\"agent {agent} failed: {e}\"); }\n    ok => ok?,\n}","handlingStrategy":"try-catch","validationCode":"let known = [\"reviewer\", \"planner\", \"deploy-agent\"];\nanyhow::ensure!(\n    known.contains(&agent),\n    \"unknown hive agent '{}' — check `hive agent --list`\",\n    agent\n);\nanyhow::ensure!(hive_available(), \"hive not on PATH\");","typeGuard":"null","tryCatchPattern":"match hive::run_agent(agent, prompt) {\n    Err(e) if e.to_string().contains(\"exited with status\") => {\n        eprintln!(\"hive agent failed; its output was streamed above — inspect it\");\n        if e.to_string().contains(\"None\") {\n            eprintln!(\"process died by signal (killed/OOM/Ctrl-C)\");\n        }\n    }\n    r => r?,\n}","preventionTips":["Validate agent names against hive's agent list before invoking","Capture or tee hive output to a log file since the error only carries the exit code","Set retry/backoff for transient hive backend failures","Monitor for signal exits (status None) which indicate kills, not hive errors"],"tags":["subprocess","exit-code","external-binary","rust"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}