Skip to content

bug(memory): session summary on shutdown always times out with structured output (gpt-5-mini) #1869

@bug-ops

Description

@bug-ops

Summary

store_session_summary_on_shutdown (PR #1833) attempts to call chat_typed_erased (structured JSON output) with a 5-second timeout. With gpt-5-mini, the structured call consistently times out, no session summary is stored, and the plain-text fallback is never attempted (timeout branch returns None immediately).

Observed

WARN zeph_core::agent: shutdown summary: LLM call timed out after 5s

summaries table remains empty after shutdown.

Root Cause

In call_llm_for_session_summary() (crates/zeph-core/src/agent/mod.rs:1769):

match tokio::time::timeout(5s, chat_typed_erased(...)).await {
    Ok(Ok(s)) => Some(s),
    Ok(Err(e)) => { /* fallback to plain */ }
    Err(_) => {
        warn!("shutdown summary: LLM call timed out after 5s");
        None  // ← no plain-text fallback attempted
    }
}

When the structured call times out, the code returns None without trying the plain-text fallback. The plain fallback is only attempted when the structured call returns an error (Ok(Err(e))), not when it times out.

Fix Options

  1. Try plain fallback on timeout too: move the plain fallback into the Err(_) arm as well
  2. Increase timeout: raise from 5s to 10–15s (or make configurable via [memory] shutdown_summary_timeout_secs)
  3. Skip structured output: always use plain chat() for shutdown summary (avoids JSON schema overhead)

Option 1 is the simplest and consistent with the intent of having a fallback.

Severity

Low — session summaries aid cross-session recall but are not critical. Sessions with more turns / faster providers may succeed.

Reproduction

printf 'Save to memory: my favorite language is Rust.\nWhat do I care about?' | \
  cargo run --features full -- --config .local/config/testing.toml 2>&1 | grep -i summar

Expected: shutdown summary stored or similar success log
Actual: shutdown summary: LLM call timed out after 5s

Verified

2026-03-15, v0.15.1, gpt-5-mini provider, pipe mode (2-turn session, 4+ messages).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmemoryzeph-memory crate (SQLite)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions