{"record":{"id":"14bc0f86c9ebbc71","repo":"chenhg5/cc-connect","slug":"session-not-found-s-14bc0f","errorCode":null,"errorMessage":"session not found: %s","messagePattern":"session not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/kimi/kimi.go","lineNumber":202,"sourceCode":"\tflagSupport := a.flagSupport\n\tif a.activeIdx >= 0 && a.activeIdx < len(a.providers) {\n\t\tif m := a.providers[a.activeIdx].Model; m != \"\" {\n\t\t\tmodel = m\n\t\t}\n\t}\n\ta.mu.Unlock()\n\n\treturn newKimiSession(ctx, cmd, extraArgs, workDir, model, mode, sessionID, extraEnv, timeout, flagSupport)\n}\n\nfunc (a *Agent) ListSessions(_ context.Context) ([]core.AgentSessionInfo, error) {\n\treturn listKimiSessions(a.workDir)\n}\n\nfunc (a *Agent) DeleteSession(_ context.Context, sessionID string) error {\n\tpath := findKimiSessionDir(sessionID)\n\tif path == \"\" {\n\t\treturn fmt.Errorf(\"session not found: %s\", sessionID)\n\t}\n\treturn os.RemoveAll(path)\n}\n\nfunc (a *Agent) Stop() error { return nil }\n\n// ── ModeSwitcher ────────────────────────────────────────────────\n\nfunc (a *Agent) SetMode(mode string) {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\ta.mode = normalizeMode(mode)\n\tslog.Info(\"kimi: mode changed\", \"mode\", a.mode)\n}\n\nfunc (a *Agent) GetMode() string {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/kimi/kimi.go#L184-L220","documentation":"Agent.DeleteSession returns this when findKimiSessionDir cannot locate a directory corresponding to the given sessionID under kimi's session storage. It guards os.RemoveAll against deleting a nonexistent or unresolvable session path.","triggerScenarios":"Calling DeleteSession(ctx, sessionID) with an ID that does not match any on-disk kimi session directory — already deleted, wrong ID format, or the session belongs to a different workDir/user.","commonSituations":"User issues /delete with a stale or mistyped session ID from chat; session was removed by kimi CLI cleanup; sessions stored under another user's HOME because the daemon runs as a different user.","solutions":["Call ListSessions first and use an exact ID from its output","Verify the session directory exists under kimiSessionsBaseDirs() for the daemon user","Treat this as idempotent: ignore the error if the goal is 'ensure deleted'","Check that the daemon's HOME matches the user who created the sessions"],"exampleFix":"// before\n_ = agent.DeleteSession(ctx, \"abc123\") // guessed ID\n// after\nsessions, _ := agent.ListSessions(ctx)\nfor _, s := range sessions {\n    if s.ID == wantID {\n        if err := agent.DeleteSession(ctx, wantID); err != nil {\n            if !strings.Contains(err.Error(), \"session not found\") { return err }\n        }\n    }\n}","handlingStrategy":"validation","validationCode":"sessions, err := agent.ListSessions(ctx)\nif err != nil { return err }\nfound := false\nfor _, s := range sessions { if s.ID == sessionID { found = true } }\nif !found { return nil } // nothing to delete","typeGuard":null,"tryCatchPattern":"if err := agent.DeleteSession(ctx, id); err != nil {\n    if strings.Contains(err.Error(), \"session not found\") {\n        return nil // idempotent delete\n    }\n    return err\n}","preventionTips":["Only pass session IDs obtained from ListSessions","Treat delete of a missing session as success (idempotency)","Run the daemon under the same user whose HOME holds the kimi sessions"],"tags":["go","session","filesystem","kimi"],"backgroundTag":"resource-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}