sigoden/aichat · info

Use '.empty session' instead

Error message

Use '.empty session' instead

What it means

The deprecated `.clear messages` command is explicitly rejected with 'Use '.empty session' instead'. The library renamed this operation: clearing messages is now performed via `.empty session`, so the old form always errors to push users to the new command.

Solutions

  1. Replace `.clear messages` with `.empty session`
  2. Update any macros or scripts that still call .clear messages
  3. Check .help for the current command list

Example fix

// before
.clear messages
// after
.empty session
Defensive patterns

Strategy: validation

Validate before calling

// sanitize legacy commands before sending to the REPL
fn normalize(cmd: &str) -> String {
    match cmd.trim() {
        ".clear messages" => ".empty session".into(),
        other => other.into(),
    }
}

Try / catch

match repl(cmd) {
    Err(e) if e.to_string().contains(".empty session") => {
        eprintln!("Deprecated command; use .empty session");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Typing `.clear messages` at the REPL prompt; macros or startup scripts still containing the old `.clear messages` command from a prior version.

Common situations: Following outdated documentation or tutorials; muscle memory from an older version of the tool; legacy macro files not updated after the command rename.

Understand the failure class

Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.

Related errors


AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09). Data as JSON: /api/errors/ad4a25fba4d80668. Report an issue: GitHub.

Appendix: source

Thrown at src/repl/mod.rs:700

                        config.write().exit_agent_session()?;
                    } else {
                        config.write().exit_session()?;
                    }
                }
                Some("rag") => {
                    config.write().exit_rag()?;
                }
                Some("agent") => {
                    config.write().exit_agent()?;
                }
                Some(_) => unknown_command()?,
                None => {
                    return Ok(true);
                }
            },
            ".clear" => match args {
                Some("messages") => {
                    bail!("Use '.empty session' instead");
                }
                _ => unknown_command()?,
            },
            _ => unknown_command()?,
        },
        None => {
            let input = Input::from_str(config, line, None);
            ask(config, abort_signal.clone(), input, true).await?;
        }
    }

    if !config.read().macro_flag {
        println!();
    }

    Ok(false)
}

View on GitHub (pinned to 82976d349a)