{"record":{"id":"9d86c7c3ffebb008","repo":"xai-org/grok-build","slug":"session-not-found","errorCode":null,"errorMessage":"session not found","messagePattern":"session not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/extensions/hooks.rs","lineNumber":218,"sourceCode":"        },\n    };\n    Some(ClientHookGroup {\n        matcher,\n        callback_ids: group.hook_callback_ids,\n        timeout,\n    })\n}\n\npub async fn handle(agent: &MvpAgent, args: &acp::ExtRequest) -> ExtResult {\n    match args.method.as_ref() {\n        \"x.ai/hooks/list\" => {\n            let req: ListRequest = super::parse_params(args)?;\n            let sid = acp::SessionId::new(req.session_id);\n\n            let result = agent\n                .list_hooks(&sid)\n                .await\n                .ok_or_else(|| anyhow::anyhow!(\"session not found\"));\n            super::to_ext_response(result)\n        }\n        \"x.ai/hooks/action\" => {\n            let req: xai_hooks_plugins_types::HooksActionRequest = super::parse_params(args)?;\n            let sid = acp::SessionId::new(req.session_id);\n\n            let result = agent\n                .execute_hooks_action(&sid, req.action)\n                .await\n                .ok_or_else(|| anyhow::anyhow!(\"session not found\"));\n            super::to_ext_response(result)\n        }\n        _ => Err(acp::Error::method_not_found()),\n    }\n}\n\n#[cfg(test)]\nmod tests {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/extensions/hooks.rs#L200-L236","documentation":"The x.ai/hooks/list extension handler builds a SessionId from the request and calls agent.list_hooks, which returns Option; None means no session with that ID is registered with the agent, and the handler converts that to the 'session not found' error. It is a lookup failure against the agent's live session registry, not a malformed request.","triggerScenarios":"Calling x.ai/hooks/list with a session_id that was never created or has already ended/closed in the agent process.","commonSituations":"Client retries with a cached session ID after agent restart; session timed out or was closed; typo'd/stale session ID passed by an IDE plugin.","solutions":["Create/reconnect a session first and use the session ID returned by the agent","Refresh the client's cached session ID instead of reusing one from before an agent restart","Handle the error by re-initializing the session and retrying the hooks/list call"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// track live sessions client-side; refuse to call with unknown IDs\nif !live_sessions.contains(&req.session_id) {\n    return Err(\"session is no longer live; re-create it\".into());\n}","typeGuard":null,"tryCatchPattern":"match ext(\"x.ai/hooks/list\", req).await {\n    Ok(resp) => resp,\n    Err(e) if e.to_string() == \"session not found\" => {\n        let sid = create_session().await?;\n        ext(\"x.ai/hooks/list\", ListRequest { session_id: sid, ..req }).await\n    }\n    Err(e) => Err(e.into()),\n}","preventionTips":["Invalidate cached session IDs on agent restart/disconnect","Listen for session-closed notifications and drop stale IDs","Create a session before any hooks call in a fresh process"],"tags":["session","lifecycle","acp"],"backgroundTag":"session-not-found","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}