xai-org/grok-build · error

{CHAT_MODE_FORK_CONFLICT}

Error message

{CHAT_MODE_FORK_CONFLICT}

What it means

`materialize_startup_for_cwd` rejects combining chat mode with a fork intent. The `CHAT_MODE_FORK_CONFLICT` constant message is bailed when `ctx.chat_mode` is true and the incoming `SessionStartupIntent` is `ForkFrom { .. }`, because forking is not a supported operation while starting in chat mode. This is a mutually-exclusive-options validation performed before any I/O or remote restore happens.

Source

Thrown at crates/codegen/xai-grok-pager/src/app/session_startup.rs:821

/// Materialize CLI intent into a concrete startup plan (I/O + remote restore).
pub async fn materialize_startup(
    ctx: MaterializeCtx,
    intent: SessionStartupIntent,
) -> anyhow::Result<MaterializedStartup> {
    let cwd = std::env::current_dir()
        .map_err(|e| anyhow::anyhow!("Failed to get cwd: {e}"))?
        .to_string_lossy()
        .to_string();
    materialize_startup_for_cwd(ctx, intent, &cwd).await
}
/// Same as [`materialize_startup`] but with an explicit process cwd (tests, headless).
pub async fn materialize_startup_for_cwd(
    ctx: MaterializeCtx,
    intent: SessionStartupIntent,
    cwd: &str,
) -> anyhow::Result<MaterializedStartup> {
    if ctx.chat_mode && matches!(intent, SessionStartupIntent::ForkFrom { .. }) {
        anyhow::bail!("{CHAT_MODE_FORK_CONFLICT}");
    }
    match intent {
        SessionStartupIntent::NewAuto => Ok(MaterializedStartup::NewAuto),
        SessionStartupIntent::NewWithId { session_id } => {
            if !ctx.has_worktree {
                ensure_session_id_available(&session_id, cwd)?;
            } else if uuid::Uuid::try_parse(&session_id).is_err() {
                anyhow::bail!("Error: --session-id must be a valid UUID (got '{session_id}').");
            }
            Ok(MaterializedStartup::NewWithId { session_id })
        }
        SessionStartupIntent::Resume {
            session_id: None,
            most_recent_for_cwd: true,
        } => {
            if ctx.chat_mode {
                anyhow::bail!("chat-mode resume requires a build with the `chat` cargo feature");
            }

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Remove the fork flags and keep chat mode, or drop chat mode if forking is what you need — pass only one of the two.
  2. If you need both behaviors, fork in a normal (non-chat) startup first, then start a chat session on the result.
  3. Check wrapper scripts/aliases for a hard-coded `--chat` flag and make fork paths skip it.
  4. Consult the CLI help to see which intents chat mode supports and choose a compatible intent (NewAuto, NewWithId, or Resume).

Example fix

// before: flags conflict
xai-grok --chat --fork-from <session-id>
// after: pick one intent
xai-grok --fork-from <session-id>   # fork without chat mode
# or
xai-grok --chat                     # plain chat session
Defensive patterns

Strategy: validation

Validate before calling

// Validate flag combinations in your wrapper before invoking the CLI.
fn flags_conflict(chat_mode: bool, fork_from: Option<&str>) -> bool {
    chat_mode && fork_from.is_some()
}
if flags_conflict(args.chat, args.fork_from.as_deref()) {
    eprintln!("--chat cannot be combined with fork; choose one.");
    std::process::exit(2);
}

Try / catch

match materialize_startup(ctx).await {
    Err(e) if e.to_string().contains("CHAT_MODE_FORK_CONFLICT")
           || e.to_string().to_lowercase().contains("fork") => {
        eprintln!("Chat mode and fork are mutually exclusive; re-run with only one.");
        std::process::exit(2);
    }
    other => other?,
}

Prevention

When it happens

Trigger: Invoking `materialize_startup`/`materialize_startup_for_cwd` with `MaterializeCtx { chat_mode: true, .. }` and `intent == SessionStartupIntent::ForkFrom { .. }` — i.e. the CLI was launched with both chat-mode and fork flags (e.g. `--chat` together with `--fork`/fork-from-session options).

Common situations: Alias or script that hard-codes `--chat` while the user adds a `--fork` flag; reusing a command template that included chat mode when trying to fork a previous session; misunderstanding that chat mode supports only NewAuto/NewWithId/Resume, not forks.

Related errors


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