{"record":{"id":"14afbae5f7a856b4","repo":"nikivdev/code","slug":"gen-agent-list-failed-14afba","errorCode":null,"errorMessage":"gen agent list failed: {}","messagePattern":"gen agent list failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/agents.rs","lineNumber":805,"sourceCode":"        GenLocation::Repo(ref repo) => {\n            let mut cmd = Command::new(\"bun\");\n            cmd.args([\n                \"run\",\n                \"--cwd\",\n                &repo.join(\"packages/opencode\").to_string_lossy(),\n                \"--conditions=browser\",\n                \"src/index.ts\",\n                \"agent\",\n                \"list\",\n            ])\n            .env(\"GEN_MODE\", \"1\");\n            apply_project_config_env(&mut cmd);\n            cmd.output().context(\"failed to run gen agent list\")?\n        }\n    };\n\n    if !output.status.success() {\n        bail!(\n            \"gen agent list failed: {}\",\n            String::from_utf8_lossy(&output.stderr)\n        );\n    }\n\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    Ok(parse_gen_agent_list(&stdout))\n}\n\nfn parse_gen_agent_list(stdout: &str) -> Vec<AgentEntry> {\n    let mut entries = Vec::new();\n    for line in stdout.lines() {\n        let line = line.trim();\n        if line.is_empty() {\n            continue;\n        }\n        if let Some((name, mode)) = parse_agent_list_line(line) {\n            if mode == \"primary\" {","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/agents.rs#L787-L823","documentation":"fetch_gen_agent_entries runs `gen agent list` and, unlike list_gen_agents, includes the subprocess stderr in the error. When the command's exit status is non-zero it bails with 'gen agent list failed: <stderr>'. This is the richer variant of the gen-listing failure used when building agent entries.","triggerScenarios":"Calling build_agent_entries/list-flows that fetch gen agent entries when `gen agent list` exits non-zero — gen binary missing prerequisites, malformed gen config, or the subcommand emitting errors on stderr.","commonSituations":"Outdated gen version whose `agent list` output contract changed; project env vars breaking gen; permission errors reading gen's agent directory.","solutions":["Read the stderr suffix in the message — it contains gen's actual error.","Run `gen agent list` manually in the resolved gen repo to reproduce.","Update/reinstall gen so the `agent list` subcommand works and its output format matches.","Fix any project config (flow.toml) env values that gen rejects."],"exampleFix":"// terminal\n$ f agents list\nError: gen agent list failed: error: unknown command 'agent'\n// fix: update gen to a version supporting `agent list`\n$ cd ~/gen && git pull && f install","handlingStrategy":"try-catch","validationCode":"command -v gen >/dev/null || { echo \"gen not installed\"; exit 1; }\ngen agent list >/dev/null 2>&1 || { echo \"gen agent list broken\"; exit 1; }","typeGuard":"fn gen_ok() -> bool {\n    std::process::Command::new(\"gen\").arg(\"agent\").arg(\"list\")\n        .output().map(|o| o.status.success()).unwrap_or(false)\n}","tryCatchPattern":"match fetch_gen_agent_entries() {\n    Err(e) => {\n        let msg = e.to_string();\n        if let Some(stderr) = msg.strip_prefix(\"gen agent list failed: \") {\n            eprintln!(\"gen reported: {stderr}\");\n        }\n    }\n    Ok(entries) => { /* use entries */ }\n}","preventionTips":["Read the stderr suffix in the error — it names the real cause.","Keep gen's version aligned with flow's expected `agent list` output.","Run `gen agent list` manually when upgrading either tool.","Check project config env vars before invoking gen-dependent commands."],"tags":["subprocess","external-tool","gen","stderr"],"backgroundTag":"subprocess-nonzero-exit","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}