sigoden/aichat · warning

No need to compress since there are no messages in the…

Error message

No need to compress since there are no messages in the session

What it means

GlobalConfig::compress_session (src/config/mod.rs:1262) refuses to compress when an active session exists but contains no user messages. Compression summarizes conversation history; with an empty session there is nothing to summarize, so it bails with 'No need to compress since there are no messages in the session'.

Solutions

  1. Send at least one message before compressing
  2. Skip compression when the session is empty (check has_user_messages() first)
  3. Exit the empty session and start fresh instead of compressing
Defensive patterns

Strategy: validation

Validate before calling

if let Some(session) = config.read().session.as_ref() {
    if !session.has_user_messages() {
        eprintln!("nothing to compress");
        return Ok(());
    }
}

Try / catch

match compress_session(&config).await {
    Err(e) if e.to_string().starts_with("No need to compress") => { /* skip silently */ }
    other => other?,
}

Prevention

When it happens

Trigger: Running `.compress` (compress_session) right after starting a fresh session; running compress after clearing all messages; compressing a loaded session file that has only system/assistant messages.

Common situations: User wants to shrink context at the start of a session out of habit; automation that compresses on a timer even when nothing new was said; resuming an old session that was previously fully compressed/cleared.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at src/config/mod.rs:1262

        print!(
            "\n📢 {}\n",
            color.italic().paint("Compressing the session."),
        );
        tokio::spawn(async move {
            if let Err(err) = Config::compress_session(&config).await {
                warn!("Failed to compress the session: {err}");
            }
            if let Some(session) = config.write().session.as_mut() {
                session.set_compressing(false);
            }
        });
    }

    pub async fn compress_session(config: &GlobalConfig) -> Result<()> {
        match config.read().session.as_ref() {
            Some(session) => {
                if !session.has_user_messages() {
                    bail!("No need to compress since there are no messages in the session")
                }
            }
            None => bail!("No session"),
        }

        let prompt = config
            .read()
            .summarize_prompt
            .clone()
            .unwrap_or_else(|| SUMMARIZE_PROMPT.into());
        let input = Input::from_str(config, &prompt, None);
        let summary = input.fetch_chat_text().await?;
        let summary_prompt = config
            .read()
            .summary_prompt
            .clone()
            .unwrap_or_else(|| SUMMARY_PROMPT.into());
        if let Some(session) = config.write().session.as_mut() {

View on GitHub (pinned to 82976d349a)