nikivdev/code · error
gen returned no output
Error message
gen returned no output
What it means
After gen exits successfully, invoke_gen_capture tries to extract structured text from gen's output and otherwise falls back to the trimmed stdout. If the output is entirely empty (or only whitespace) even though the exit status was success, it bails with 'gen returned no output' — a contract violation between flow and gen.
Source
Thrown at src/agents.rs:1079
cmd.output().context("failed to run gen from repo")
}
}?;
if !output.status.success() {
bail!("gen exited with status: {}", output.status);
}
let stdout = String::from_utf8_lossy(&output.stdout);
if let Some(text) = extract_text_from_gen_output(&stdout) {
return Ok(text);
}
let trimmed = stdout.trim();
if !trimmed.is_empty() {
return Ok(trimmed.to_string());
}
bail!("gen returned no output");
}
fn invoke_gen_capture_streaming(location: &GenLocation, prompt: &str) -> Result<String> {
let mut cmd = match location {
GenLocation::Binary(path) => {
let mut cmd = Command::new(path);
cmd.args(["run", "--format", "json", prompt])
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::inherit());
cmd
}
GenLocation::Repo(repo) => {
let mut cmd = Command::new("bun");
cmd.args([
"run",
"--cwd",
&repo.join("packages/opencode").to_string_lossy(),View on GitHub (pinned to a747e741ae)
Solutions
- Run gen manually with the same prompt to inspect its raw stdout.
- Upgrade or downgrade gen so its output format matches what extract_text_from_gen_output expects (version alignment with flow).
- Check gen's own logs/config for silent failures (missing API key producing empty success).
- Ensure nothing in the calling environment redirects or discards gen's stdout.
Example fix
// before $ f flow-agent "summarize" Error: gen returned no output // after $ gen --version && echo 'summarize' | gen # inspect raw output $ # align gen version with flow (git pull in GEN_REPO, reinstall), retry
Defensive patterns
Strategy: fallback
Validate before calling
out=$(gen "$PROMPT" 2>/dev/null); [ -n "$(echo "$out" | tr -d '[:space:]')" ] \
|| { echo "gen produced empty output"; exit 1; } Type guard
fn has_output(stdout: &str) -> bool {
!stdout.trim().is_empty()
} Try / catch
match invoke_gen_capture(&loc, prompt) {
Err(e) if e.to_string() == "gen returned no output" => {
eprintln!("gen succeeded silently; check gen version/output format.");
// fall back to a direct gen invocation to capture raw output
}
other => other?,
} Prevention
- Pin gen and flow versions so output formats stay compatible.
- Monitor gen upgrades for output-format changes affecting extract_text_from_gen_output.
- Check gen's API key/config after any empty-success result.
- Test gen's raw stdout manually when integration tests report empty output.
When it happens
Trigger: gen exits 0 but prints nothing (or only unparseable-empty output): silently failing model call inside gen, gen writing results elsewhere, or a gen version whose output format no longer matches extract_text_from_gen_output.
Common situations: Version skew where gen changed its JSON output shape so extraction fails and stdout is blank; gen success-without-work edge cases; redirected/swallowed stdout in wrappers.
Related errors
- gen agent list failed
- gen agent list failed: {}
- gen exited with status: {}
- resolver {} returned empty output for {}
- kimi returned empty output
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/5115c068d3cd0ad2.
Report an issue: GitHub.