nikivdev/code · error
gen agent list failed: {}
Error message
gen agent list failed: {} What it means
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.
Source
Thrown at src/agents.rs:805
GenLocation::Repo(ref repo) => {
let mut cmd = Command::new("bun");
cmd.args([
"run",
"--cwd",
&repo.join("packages/opencode").to_string_lossy(),
"--conditions=browser",
"src/index.ts",
"agent",
"list",
])
.env("GEN_MODE", "1");
apply_project_config_env(&mut cmd);
cmd.output().context("failed to run gen agent list")?
}
};
if !output.status.success() {
bail!(
"gen agent list failed: {}",
String::from_utf8_lossy(&output.stderr)
);
}
let stdout = String::from_utf8_lossy(&output.stdout);
Ok(parse_gen_agent_list(&stdout))
}
fn parse_gen_agent_list(stdout: &str) -> Vec<AgentEntry> {
let mut entries = Vec::new();
for line in stdout.lines() {
let line = line.trim();
if line.is_empty() {
continue;
}
if let Some((name, mode)) = parse_agent_list_line(line) {
if mode == "primary" {View on GitHub (pinned to a747e741ae)
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.
Example fix
// terminal $ f agents list Error: gen agent list failed: error: unknown command 'agent' // fix: update gen to a version supporting `agent list` $ cd ~/gen && git pull && f install
Defensive patterns
Strategy: try-catch
Validate before calling
command -v gen >/dev/null || { echo "gen not installed"; exit 1; }
gen agent list >/dev/null 2>&1 || { echo "gen agent list broken"; exit 1; } Type guard
fn gen_ok() -> bool {
std::process::Command::new("gen").arg("agent").arg("list")
.output().map(|o| o.status.success()).unwrap_or(false)
} Try / catch
match fetch_gen_agent_entries() {
Err(e) => {
let msg = e.to_string();
if let Some(stderr) = msg.strip_prefix("gen agent list failed: ") {
eprintln!("gen reported: {stderr}");
}
}
Ok(entries) => { /* use entries */ }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Outdated gen version whose `agent list` output contract changed; project env vars breaking gen; permission errors reading gen's agent directory.
Related errors
- gen agent list failed
- gen exited with status: {}
- gen returned no output
- 'codanna init' exited with status {}
- 'codanna index' exited with status {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/14afbae5f7a856b4.
Report an issue: GitHub.