xai-org/grok-build · error
No session found for current directory. Use 'grok' to start
Error message
No session found for current directory. Use 'grok' to start a new session.
What it means
When resuming an existing session for the current directory, list_summaries(Some(cwd)) is queried and the first summary admitted by the selection filter is taken. If no persisted session for this cwd passes the filter, the resolver fails with this guidance message telling the user to start a fresh session.
Source
Thrown at crates/codegen/xai-grok-pager/src/app/session_startup.rs:758
///
/// When the parent lives under another directory, the fork effect sets `newCwd` to that parent session cwd; preflight must use the same path.
pub fn effective_fork_new_cwd(process_cwd: &str, parent_cwd: Option<&Path>) -> String {
parent_cwd
.map(|p| p.to_string_lossy().into_owned())
.unwrap_or_else(|| process_cwd.to_string())
}
pub use xai_grok_shell::session::persistence::RecentSessionSelection;
/// Resolve most-recent session id for cwd, or error.
async fn most_recent_session_id(
cwd: &str,
selection: RecentSessionSelection,
) -> anyhow::Result<(String, Option<String>)> {
let summaries = xai_grok_shell::session::persistence::list_summaries(Some(cwd)).await?;
let first = summaries
.iter()
.find(|summary| selection.admits(summary))
.ok_or_else(|| {
anyhow::anyhow!(
"No session found for current directory. \
Use 'grok' to start a new session."
)
})?;
Ok((first.info.id.to_string(), first.display_title_opt()))
}
/// `AuthManager` for direct grok.com calls made outside the agent (pre-ACP `--continue` conversation listing, the GCS restore effect).
/// Wires the auth-provider refresher before the first `auth()`.
/// Without it, environments that mint credentials via `auth_provider_command` report `NoOauth`.
pub(crate) fn pre_acp_auth_manager(
agent_config: &xai_grok_shell::agent::config::Config,
) -> std::sync::Arc<xai_grok_shell::auth::AuthManager> {
let auth = std::sync::Arc::new(xai_grok_shell::auth::AuthManager::new(
&xai_grok_shell::util::grok_home::grok_home(),
agent_config.grok_com_config.clone(),
));
auth.configure_refresher(
agent_config.grok_com_config.auth_provider_command.clone(),View on GitHub (pinned to bc7f02eddd)
Solutions
- Start a new session with plain 'grok' as the message suggests
- Verify you are in the exact directory (canonical path) where the original session was created
- Check the session storage location for existing summaries (confirm they were not wiped or relocated)
- If resuming by title/ID, verify the filter matches an existing summary
Example fix
// before: resume in a dir with no sessions grok resume // after: start fresh or pass an explicit id mkdir -p ~/project && cd ~/project && grok // or: grok resume <session-id>
Defensive patterns
Strategy: try-catch
Validate before calling
// check for a resumable session before invoking resume
let summaries = xai_grok_shell::session::persistence::list_summaries(Some(cwd)).await?;
let resumable = summaries.iter().any(|s| selection.admits(s));
if !resumable {
eprintln!("no session here; starting new one instead");
start_new_session().await?;
} Try / catch
match resume_session_for_cwd(cwd, selection).await {
Ok((id, title)) => restore(id, title).await,
Err(e) if e.to_string().contains("No session found for current directory") => {
start_new_session().await
}
Err(e) => Err(e),
} Prevention
- Resume only from the exact directory (canonical path) where the session was created
- Fall back to starting a new session when resume misses
- Back up the session storage directory if sessions matter across machines
- When filtering by id/title, verify against the summary list first
When it happens
Trigger: Running a resume command (e.g. grok resume) in a directory with no previously saved session summaries, or where the selection predicate (admits) excludes all candidates — e.g. filtering by title/ID/age that matches nothing.
Common situations: Starting a project in a brand-new directory; resuming after session storage was cleared or moved to another machine; cwd differs (symlink vs canonical path, trailing path differences) from the one recorded at save time; an ID/title filter typo.
Related errors
- {e:#}; {title_miss_hint}
- {} (session id: {session_id})
- Failed to load config: {}
- session folder is unavailable
- session '{session_name}' is already running on port {} (use
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/91eeb9dc6f310e3e.
Report an issue: GitHub.