xai-org/grok-build · error

{}

Error message

{}

What it means

The pager CLI bails when `--chat` mode is requested together with leader mode, because the two startup paths are mutually exclusive: chat mode drives a single conversational session while leader mode orchestrates subordinate sessions. The constant `session_startup::CHAT_MODE_LEADER_CONFLICT` carries the explanatory message and `anyhow::bail!` aborts startup with the formatted string `{}`.

Source

Thrown at crates/codegen/xai-grok-pager/src/app/mod.rs:693

        &raw_config,
        remote_settings.as_ref(),
        true,
        requested_confinement,
    );
    tracing::info!(
        use_leader,
        ?policy_disable_reason,
        sandbox_profile = ?requested_confinement,
        // The other fields cannot distinguish this from leader mode being off already while a sandbox is on
        leader_disabled_by_sandbox = disabled_by_confinement.is_some(),
        prefetch_ms = prefetch_elapsed.as_millis() as u64,
        "pager TUI leader mode resolved"
    );
    if let Some(profile) = disabled_by_confinement {
        warn_leader_disabled_by_sandbox(profile);
    }
    if session_startup::chat_mode_conflicts_with_leader(args.chat(), use_leader) {
        anyhow::bail!("{}", session_startup::CHAT_MODE_LEADER_CONFLICT);
    }
    if args.trust {
        match std::env::current_dir() {
            Ok(cwd) => xai_grok_workspace::folder_trust::grant_folder_trust(&cwd),
            Err(e) => {
                tracing::warn!(error = %e, "--trust: failed to resolve cwd; folder not trusted")
            }
        }
    }
    if let Some(reason) = policy_disable_reason {
        tokio::spawn(xai_grok_shell::leader::kill_stale_reachable_leaders(reason));
    }
    if let Some(err) =
        session_startup::chat_mode_flag_conflict(args.chat(), args.fork_session, args.restore_code)
    {
        anyhow::bail!("{err}");
    }
    #[cfg(feature = "local-workspace")]

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Remove the `--chat` flag when leader mode is enabled (or vice versa) so only one mode is active
  2. Check shell aliases, wrapper scripts, and config files for a hardcoded `--chat`
  3. Inspect the leader-mode env/flags that set `use_leader` and disable them for chat runs

Example fix

// before
grok-pager --chat --leader
// after
grok-pager --chat        # or: grok-pager --leader (without --chat)
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_no_chat_leader_conflict(chat: bool, use_leader: bool) -> Result<(), String> {
    if chat && use_leader { Err("--chat cannot be combined with leader mode".into()) } else { Ok(()) }
}

Type guard

fn chat_without_leader(chat: bool, use_leader: bool) -> bool { chat && !use_leader }

Try / catch

match run_pager(args) {
    Err(e) if e.to_string().contains("CHAT_MODE_LEADER_CONFLICT") || e.to_string().to_lowercase().contains("leader") => eprintln!("Drop --chat or leader mode: {e}"),
    Err(e) => eprintln!("startup failed: {e}"),
    Ok(_) => {},
}

Prevention

When it happens

Trigger: Running the binary with both a chat-mode flag (e.g. `--chat`) and any flag/env that enables leader mode; `session_startup::chat_mode_conflicts_with_leader(args.chat(), use_leader)` returns true and mod.rs:693 bails.

Common situations: Shell aliases or wrapper scripts that always pass `--chat` while the user separately enables leader mode via config or env; combining a documented chat quick-start command with an existing leader-mode setup.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/be36cbdf800f236a. Report an issue: GitHub.