aaif-goose/goose · error · anyhow::Error

no text provided for prompt in headless mode

Error message

no text provided for prompt in headless mode

What it means

In headless (non-interactive) execution the CLI must be given prompt text, either as CLI arguments or via stdin. If the assembled `contents` is empty when no interactive branch applies, goose fails before creating a session.

Source

Thrown at crates/goose-cli/src/cli.rs:1955

    if run_behavior.interactive {
        session.interactive(input_config.contents).await
    } else if let Some(contents) = input_config.contents {
        let session_start = std::time::Instant::now();
        let session_type = if recipe.is_some() { "recipe" } else { "run" };

        tracing::info!(
            monotonic_counter.goose.session_starts = 1,
            session_type,
            interactive = false,
            "Headless session started"
        );

        let result = session.headless(contents).await;
        log_session_completion(&session, session_start, session_type, result.is_ok()).await;
        result
    } else {
        Err(anyhow::anyhow!(
            "no text provided for prompt in headless mode"
        ))
    }
}

async fn handle_gateway_command(command: GatewayCommand) -> Result<()> {
    use crate::commands::gateway;

    match command {
        GatewayCommand::Status {} => gateway::handle_gateway_status().await,
        GatewayCommand::Start {
            gateway_type,
            bot_token,
        } => {
            let platform_config = serde_json::json!({ "bot_token": bot_token });
            gateway::handle_gateway_start(gateway_type, platform_config).await
        }
        GatewayCommand::Stop { gateway_type } => gateway::handle_gateway_stop(gateway_type).await,

View on GitHub (pinned to 3810898a74)

Solutions

  1. Pass the prompt text explicitly, e.g. `goose run "your instruction"`
  2. Pipe non-empty content via the stdin headless path (`goose run -i -` with piped text)
  3. If an interactive REPL was intended, run goose inside a real terminal
  4. Guard wrapper scripts: fail early when the prompt variable is empty

Example fix

# before
goose run                        # no text, non-TTY stdin -> error

# after
goose run "Summarize this repository"
# or
cat prompt.txt | goose run -i -
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
PROMPT="$1"
[ -n "$PROMPT" ] || { echo 'error: prompt text is required in headless mode' >&2; exit 2; }
exec goose run "$PROMPT"

Prevention

When it happens

Trigger: Invoking the headless path with no prompt argument and empty/closed stdin (e.g. `goose run` inside CI with no input), or piping an empty string into the stdin prompt path.

Common situations: CI jobs or cron scripts calling goose without arguments; `echo "" | goose run` style pipelines; scripts assuming goose falls back to interactive mode when stdin is not a TTY.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/d98b011ff1a1f2b3. Report an issue: GitHub.