affaan-m/ECC · error · anyhow::Error

Session not found

Error message

Session not found: {value}

What it means

Also from `resolve_session_id`: when the provided value is not `"latest"`, the helper looks it up via `db.get_session(value)` and returns this error if no session with that ID exists. The `value` is interpolated into the message so you can see which identifier failed. Only exact, existing session IDs resolve successfully.

Solutions

  1. Run `ecc sessions list` and copy the exact session ID.
  2. Check for typos/truncation in the ID (shell line-wrap copy errors are common).
  3. Confirm you're using the right data directory/profile — IDs don't cross stores.
  4. If the session was deleted, use `latest` or an existing session instead.

Example fix

// before
$ ecc graph show --session abc-12   # truncated
error: Session not found: abc-12
// after
$ ecc sessions list
$ ecc graph show --session abc-1234-5678-...
Defensive patterns

Strategy: validation

Validate before calling

# Resolve from the live list, never from memory
SESSION_ID=$(ecc sessions list --json | jq -r '.[] | select(.id == "'$WANT_ID'") | .id // empty')
[ -n "$SESSION_ID" ] || { echo "session $WANT_ID not in this store" >&2; exit 1; }

Try / catch

match resolve_session_id(&db, value) {
    Err(e) if e.to_string().starts_with("Session not found") => {
        eprintln!("'{value}' is not a session in this store; run 'ecc sessions list'");
    }
    Err(e) => return Err(e),
    Ok(id) => use_session(id),
}

Prevention

When it happens

Trigger: Passing `--session <value>` with a mistyped, truncated, or already-deleted session ID; passing a session title/path instead of the ID; referencing a session from a different database/profile.

Common situations: Hand-copied IDs with missing characters; old IDs after a database reset; environment variable pointing at a stale session; confusing short session names with the canonical UUID-style ID.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/794addda0d61cc0e. Report an issue: GitHub.

Appendix: source

Thrown at ecc2/src/main.rs:2918

        }) => {
            session::manager::run_session(&cfg, &session_id, &task, &agent, &cwd).await?;
        }
    }

    Ok(())
}

fn resolve_session_id(db: &session::store::StateStore, value: &str) -> Result<String> {
    if value == "latest" {
        return db
            .get_latest_session()?
            .map(|session| session.id)
            .ok_or_else(|| anyhow::anyhow!("No sessions found"));
    }

    db.get_session(value)?
        .map(|session| session.id)
        .ok_or_else(|| anyhow::anyhow!("Session not found: {value}"))
}

fn sync_runtime_session_metrics(
    db: &session::store::StateStore,
    cfg: &config::Config,
) -> Result<()> {
    db.refresh_session_durations()?;
    db.sync_cost_tracker_metrics(&cfg.cost_metrics_path())?;
    db.sync_tool_activity_metrics(&cfg.tool_activity_metrics_path())?;
    let _ = session::manager::enforce_session_heartbeats(db, cfg)?;
    let _ = session::manager::enforce_budget_hard_limits(db, cfg)?;
    Ok(())
}

fn sync_memory_connector(
    db: &session::store::StateStore,
    cfg: &config::Config,
    name: &str,

View on GitHub (pinned to 8321021c54)