{"record":{"id":"13f015b821aaa8cf","repo":"aaif-goose/goose","slug":"failed-to-fetch-updated-session","errorCode":null,"errorMessage":"Failed to fetch updated session: {}","messagePattern":"Failed to fetch updated session: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose/src/agents/agent.rs","lineNumber":2044,"sourceCode":"                        &session_config.id,\n                        &response.clone().with_visibility(true, false),\n                    )\n                    .await?;\n\n                // Check if this was a command that modifies conversation history\n                let modifies_history = crate::agents::execute_commands::COMPACT_TRIGGERS\n                    .contains(&message_text.trim())\n                    || message_text.trim() == \"/clear\";\n\n                return Ok(Box::pin(async_stream::try_stream! {\n                    yield AgentEvent::Message(user_message);\n                    yield AgentEvent::Message(response);\n\n                    // After commands that modify history, notify UI that history was replaced\n                    if modifies_history {\n                        let updated_session = session_manager.get_session(&session_config.id, true)\n                            .await\n                            .map_err(|e| anyhow!(\"Failed to fetch updated session: {}\", e))?;\n                        let updated_conversation = updated_session\n                            .conversation\n                            .ok_or_else(|| anyhow!(\"Session has no conversation after history modification\"))?;\n                        yield AgentEvent::HistoryReplaced(updated_conversation);\n                    }\n                }));\n            }\n            Ok(Some(resolved_message)) => {\n                session_manager\n                    .add_message(\n                        &session_config.id,\n                        &user_message.clone().with_visibility(true, false),\n                    )\n                    .await?;\n                session_manager\n                    .add_message(\n                        &session_config.id,\n                        &resolved_message.clone().with_visibility(false, true),","sourceCodeStart":2026,"sourceCodeEnd":2062,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose/src/agents/agent.rs#L2026-L2062","documentation":"After processing a history-modifying slash command (members of execute_commands::COMPACT_TRIGGERS like /compact, or /clear), the reply stream re-fetches the session with get_session(&id, true) (include_messages) to emit a HistoryReplaced event. This error means that re-fetch failed at the SessionManager level — session record unreadable, missing, or storage error — after the command already modified history.","triggerScenarios":"Running /compact or /clear when the session file/DB entry was deleted or moved mid-run, is corrupted (deserialization fails), or the storage backend returned an I/O error (permissions, disk).","commonSituations":"Session files under the goose sessions directory removed by cleanup tools while goose runs; partial writes from a crash leaving a corrupt session file; read-only or full disk; sessions synced/overwritten by another process.","solutions":["Check the session file/record still exists and is readable in the sessions directory","Retry the command once transient I/O is ruled out — history was already modified, so a re-fetch may succeed","Repair or archive the corrupted session and continue in a new session","Free disk / fix permissions on the goose config directory"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before issuing /compact or /clear, confirm the session is readable:\nif session_manager.get_session(&session_id, true).await.is_err() {\n    anyhow::bail!(\"session {session_id} unreadable; fix storage before history commands\");\n}","typeGuard":"fn session_fetch_failed(e: &anyhow::Error) -> bool {\n    e.to_string().contains(\"Failed to fetch updated session\")\n}","tryCatchPattern":"// inside the try_stream: one bounded retry, then degrade gracefully\nlet updated = match session_manager.get_session(&session_config.id, true).await {\n    Ok(s) => Some(s),\n    Err(first) => match session_manager.get_session(&session_config.id, true).await {\n        Ok(s) => Some(s),\n        Err(_) => { tracing::error!(\"{first}\"); None }\n    },\n};\nif let Some(s) = updated { /* yield HistoryReplaced */ }","preventionTips":["Don't delete or move session files while a goose session is live","Monitor free disk and permissions on the goose config directory","Back up the sessions directory before bulk cleanup"],"tags":["rust","goose","session","storage","slash-commands","compact"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}