nikivdev/code · error

No prompt provided for flow agent.

Error message

No prompt provided for flow agent.

What it means

run_flow_agent_capture resolves the gen location (bailing earlier if gen is missing) and then validates that the prompt is non-empty (after trimming whitespace) before building the flow prompt. An empty/whitespace-only prompt causes this bail; the function exists to capture gen's output rather than stream it.

Source

Thrown at src/agents.rs:952

    cmd.arg(prompt)
        .stdin(Stdio::inherit())
        .stdout(Stdio::inherit())
        .stderr(Stdio::inherit())
        .status()
        .context("failed to run opencode")
}

/// Run the flow agent and capture the final text output.
pub fn run_flow_agent_capture(prompt: &str) -> Result<String> {
    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()
        )
    })?;

    if prompt.trim().is_empty() {
        bail!("No prompt provided for flow agent.");
    }

    let full_prompt = build_flow_prompt(prompt)?;
    invoke_gen_capture(&gen_loc, &full_prompt)
}

/// Run the flow agent and stream text output while capturing the final response.
pub fn run_flow_agent_capture_streaming(prompt: &str) -> Result<String> {
    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()
        )
    })?;

    if prompt.trim().is_empty() {
        bail!("No prompt provided for flow agent.");
    }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Pass non-empty prompt text to run_flow_agent_capture.
  2. Trim and validate the prompt at the call site before invoking.
  3. Ensure the config field or variable feeding the prompt is populated.
  4. If the prompt should come from a file/stdin, read and verify it before calling.

Example fix

// before
run_flow_agent_capture(loc, "")?; // panics/bails
// after
let prompt = cfg.prompt.trim();
anyhow::ensure!(!prompt.is_empty(), "prompt required");
run_flow_agent_capture(loc, prompt)?;
Defensive patterns

Strategy: validation

Validate before calling

let p = prompt.trim();
if p.is_empty() { return Err(anyhow::anyhow!("prompt required")); }
run_flow_agent_capture(&loc, p)?;

Type guard

fn is_valid_prompt(p: &str) -> bool {
    !p.trim().is_empty()
}

Try / catch

match run_flow_agent_capture(&loc, prompt) {
    Err(e) if e.to_string().contains("No prompt provided for flow agent") => {
        eprintln!("Supply non-empty prompt text.");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling the public run_flow_agent_capture with "", whitespace, or a programmatically supplied prompt that resolved to empty; the gen-location check already passed at this point.

Common situations: Library/CLI callers building a flow-agent request from an empty config field or unset variable; UI passing through an untouched input box.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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