chenhg5/cc-connect · warning
no session found for project %q with key %q
Error message
no session found for project %q with key %q
What it means
findAgentSessionID, after scanning all candidate session files, returns the best (newest) definite match; if none matched and there was no definite error, it fails with `no session found for project %q with key %q`. matchesProject supports <project>.json, <project>_<hash>.json, <project>_ws_<hash>.json, and legacy <project>.sessions.json naming, so this means no file/session matching both the project and key was found.
Source
Thrown at cmd/cc-connect/session_id.go:140
best = &candidate{agentID: agentID, updatedAt: updatedAt}
}
}
}
}
// If the newest match has a valid agent ID, return it.
// If an error match is newer than the best valid match, prefer the error
// (the newest session is still starting and the older ID is stale).
if best != nil {
if errCandidate != nil && errCandidate.updatedAt > best.updatedAt {
return "", definiteErr
}
return best.agentID, nil
}
if definiteErr != nil {
return "", definiteErr
}
return "", fmt.Errorf("no session found for project %q with key %q", project, sessionKey)
}
// matchesProject checks if a filename belongs to the given project.
// Matches: <project>.json, <project>_<hash>.json, <project>_ws_<hash>.json,
// <project>.sessions.json (legacy).
//
// The suffix after <project>_ must look like a hash (hex) or follow the
// ws_<hash> pattern to avoid false positives with other projects whose
// name starts with the same prefix (e.g. "mybot_extra" vs "mybot").
func matchesProject(filename, project string) bool {
if !strings.HasSuffix(filename, ".json") {
return false
}
base := strings.TrimSuffix(filename, ".json")
// Try exact match first (covers <project>.json).
if base == project {
return true
}View on GitHub (pinned to 4000b2338a)
Solutions
- List the sessions directory (e.g. ~/.claude/projects/) and check the exact filenames for your project
- Re-check the --project value — it must match how the agent encodes the workspace path (usually the absolute path)
- Start a new agent session to create a session file, then retry agent-sid
Example fix
// before cc-connect agent-sid --project ~/Work/myproj --key abc // after cc-connect agent-sid --project /home/me/Work/myproj --key abc # absolute path as encoded by the agent
Defensive patterns
Strategy: fallback
Validate before calling
ls ~/.claude/projects/ | grep -i myproj # confirm session files exist before querying
Prevention
- Use the absolute project path exactly as the agent encodes it
- Confirm sessions exist before scripting lookups
- Handle the not-found case in scripts by starting a new session
When it happens
Trigger: Running `cc-connect agent-sid` with a project name or session key that matches no session file: project path mangled (slashes/hash encoding), wrong key string, or no sessions ever created for that project.
Common situations: Typo in --project or --key, running from a machine where the agent never started, project renamed/moved so the encoded hash no longer matches, expecting legacy naming for a session created with the new naming scheme (or vice versa).
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- opencode: session list: %w
- cannot read sessions directory %s: %w
- session %q referenced by key %q not found in %s
- agent session ID not yet available (session may still be sta
- read sessions dir: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/217684252e52c07c.
Report an issue: GitHub.