nikivdev/code · error

gen agent list failed

Error message

gen agent list failed

What it means

list_gen_agents shells out to the external `gen` binary to list agents and propagates only its exit status. When the subprocess exits non-zero it bails with the generic message 'gen agent list failed' without including stderr, so the underlying cause is hidden. It is a thin wrapper failure over the external tool.

Source

Thrown at src/agents.rs:770

                &repo.join("packages/opencode").to_string_lossy(),
                "--conditions=browser",
                "src/index.ts",
                "agent",
                "list",
            ])
            .env("GEN_MODE", "1")
            .stdin(Stdio::inherit())
            .stdout(Stdio::inherit())
            .stderr(Stdio::inherit());
            apply_project_config_env(&mut cmd);
            cmd.status().context("failed to run gen agent list")?
        }
    };

    if status.success() {
        Ok(())
    } else {
        bail!("gen agent list failed");
    }
}

fn fetch_gen_agent_entries() -> Result<Vec<AgentEntry>> {
    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()
        )
    })?;

    let output = match gen_loc {
        GenLocation::Binary(ref path) => Command::new(path)
            .args(["agent", "list"])
            .output()
            .context("failed to run gen agent list")?,
        GenLocation::Repo(ref repo) => {
            let mut cmd = Command::new("bun");

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run `gen agent list` directly to see the real error output.
  2. Verify gen is installed and on PATH and that GEN_REPO (if set) points to a valid gen repo (`gen_repo_hint()` output).
  3. Reinstall or update gen (`cd <gen-repo> && f install`).
  4. Check project config env vars that apply_project_config_env injects for anything breaking gen.
Defensive patterns

Strategy: retry

Validate before calling

gen agent list >/dev/null 2>&1 || { echo "gen broken: run 'gen agent list' to diagnose"; exit 1; }
f agents list

Type guard

fn gen_available() -> bool {
    std::process::Command::new("gen")
        .arg("--version").output()
        .map(|o| o.status.success()).unwrap_or(false)
}

Try / catch

if let Err(e) = list_gen_agents(&gen_loc) {
    if e.to_string() == "gen agent list failed" {
        // rerun `gen agent list` manually to surface the hidden stderr
    }
}

Prevention

When it happens

Trigger: Running `f agents list` when the underlying `gen agent list` subprocess returns a non-zero exit status (gen crashed, bad config, missing agent store, incompatible gen version).

Common situations: GEN_REPO pointing at an invalid/broken checkout; gen not fully installed; gen's agent list subcommand renamed or failing due to environment variables from apply_project_config_env.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/f377b7da0aa75411. Report an issue: GitHub.