{"record":{"id":"744bd8e38a90e932","repo":"nikivdev/code","slug":"gen-exited-with-status","errorCode":null,"errorMessage":"gen exited with status: {}","messagePattern":"gen exited with status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/agents.rs","lineNumber":1066,"sourceCode":"                \"run\",\n                \"--cwd\",\n                &repo.join(\"packages/opencode\").to_string_lossy(),\n                \"--conditions=browser\",\n                \"src/index.ts\",\n                \"run\",\n                \"--format\",\n                \"json\",\n                prompt,\n            ])\n            .env(\"GEN_MODE\", \"1\")\n            .stdin(Stdio::null());\n            apply_project_config_env(&mut cmd);\n            cmd.output().context(\"failed to run gen from repo\")\n        }\n    }?;\n\n    if !output.status.success() {\n        bail!(\"gen exited with status: {}\", output.status);\n    }\n\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    if let Some(text) = extract_text_from_gen_output(&stdout) {\n        return Ok(text);\n    }\n\n    let trimmed = stdout.trim();\n    if !trimmed.is_empty() {\n        return Ok(trimmed.to_string());\n    }\n\n    bail!(\"gen returned no output\");\n}\n\nfn invoke_gen_capture_streaming(location: &GenLocation, prompt: &str) -> Result<String> {\n    let mut cmd = match location {\n        GenLocation::Binary(path) => {","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/agents.rs#L1048-L1084","documentation":"invoke_gen_capture spawns the gen binary (Binary or repo location) to run the flow prompt and checks the exit status. A non-zero status bails with 'gen exited with status: <status>'. The raw gen output is discarded on failure, so the underlying gen error must be reproduced manually.","triggerScenarios":"gen returns non-zero while executing the flow prompt — bad GEN_REPO checkout, gen build failure, gen-side error processing the prompt, or project-config env vars breaking gen.","commonSituations":"GEN_REPO env var set to a path that is not a working gen repo; gen binary out of date relative to flow's expectations; network/model-credential failure inside gen; large prompt causing gen to fail.","solutions":["Run gen directly with the same prompt/location to see its real error output.","Verify GEN_REPO points to a valid gen checkout or install the binary (`cd <gen-repo> && f install`, or set GEN_REPO per gen_repo_hint()).","Rebuild/update gen (`cargo build` / git pull in the gen repo).","Check env vars injected by apply_project_config_env for anything gen rejects."],"exampleFix":"// before\n$ f flow-agent \"do thing\"\nError: gen exited with status: exit status: 101\n// after\n$ cd \"$GEN_REPO\" && git pull && cargo build --release && f install\n$ f flow-agent \"do thing\"   # succeeds","handlingStrategy":"retry","validationCode":"[ -n \"${GEN_REPO:-}\" ] && [ -d \"$GEN_REPO/.git\" ] && gen --version >/dev/null \\\n  || { echo \"GEN_REPO invalid or gen missing\"; exit 1; }","typeGuard":"fn gen_ready() -> bool {\n    std::process::Command::new(\"gen\").arg(\"--version\").output()\n        .map(|o| o.status.success()).unwrap_or(false)\n}","tryCatchPattern":"match invoke_gen_capture(&loc, prompt) {\n    Err(e) if e.to_string().starts_with(\"gen exited with status\") => {\n        eprintln!(\"gen failed; run gen manually with the same prompt for details.\");\n        // fix install/auth, then retry\n    }\n    other => other?,\n}","preventionTips":["Keep GEN_REPO pointing at a valid, up-to-date gen checkout.","Rebuild/reinstall gen after pulling changes.","Verify gen runs the same prompt successfully before blaming flow.","Review project config env vars passed into the gen subprocess."],"tags":["subprocess","gen","exit-code"],"backgroundTag":"subprocess-nonzero-exit","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}