astrid-runtime/astrid · error

headless approval automation is unsupported: approvals canno

Error message

headless approval automation is unsupported: approvals cannot be correlated to this run; remove --yes, --yolo, or --autonomous

What it means

`ensure_headless_auto_approve_rejected` fails closed when a CLI invocation both requests automatic approval (`--yes`, `--yolo`, or `--autonomous`) and runs through a headless route. The guard exists because in headless mode approvals cannot be correlated to the originating run, so auto-approving is unsafe and unsupported.

Source

Thrown at crates/astrid-cli/src/dispatch.rs:105

        std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin_text)?;
        if !stdin_text.is_empty() {
            commands::headless::run_headless(
                stdin_text,
                output_format,
                cli.session_name,
                cli.print_session,
            )
            .await?;
            return Ok(ExitCode::SUCCESS);
        }
    }

    dispatch_subcommand(cli.command, output_format).await
}

fn ensure_headless_auto_approve_rejected(auto_approve: bool, headless_route: bool) -> Result<()> {
    if auto_approve && headless_route {
        anyhow::bail!(headless::AUTO_APPROVE_UNSUPPORTED_MESSAGE);
    }
    Ok(())
}

fn should_check_for_update(cli: &Cli) -> bool {
    cli.prompt.is_none()
        && !matches!(
            cli.command,
            Some(
                Commands::Update(_)
                    | Commands::Hook(_)
                    | Commands::Completions(_)
                    | Commands::Mcp { .. }
                    | Commands::Init { offline: true, .. }
                    | Commands::Distro {
                        command: DistroCommands::Apply { offline: true, .. }
                    }
            )

View on GitHub (pinned to affd8760f4)

Solutions

  1. Remove the `--yes`, `--yolo`, or `--autonomous` flag from the headless invocation.
  2. Run the command interactively if auto-approval is genuinely required.
  3. Use an explicit, auditable approval mechanism appropriate for headless runs instead of blanket auto-approve flags.

Example fix

// before
astrid --yolo run capsule:build
// after
astrid run capsule:build
Defensive patterns

Strategy: validation

Validate before calling

const AUTO_APPROVE_FLAGS: [&str; 3] = ["--yes", "--yolo", "--autonomous"];
if is_headless_environment() && AUTO_APPROVE_FLAGS.iter().any(|f| std::env::args().any(|a| a == *f)) {
    return Err("auto-approve flags are unsupported in headless runs".into());
}

Type guard

fn headless_with_auto_approve(cli: &Cli, headless_route: bool) -> bool {
    cli.auto_approve && headless_route
}

Try / catch

if let Err(e) = astrid::run(cli) {
    if e.to_string().contains("headless approval automation is unsupported") {
        eprintln!("re-run without --yes/--yolo/--autonomous");
        std::process::exit(2);
    }
    return Err(e);
}

Prevention

When it happens

Trigger: Invoking a run subcommand with any auto-approve flag set while the dispatch is on a headless route, e.g. `astrid --yes run ...` in a non-interactive/headless context.

Common situations: CI pipelines or scripts copying interactive flags into non-interactive invocations; users automating runs with `--yolo` after switching from a TTY to headless execution.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/a28b02da37eb63d2. Report an issue: GitHub.