{"record":{"id":"4d1ede607995f485","repo":"astrid-runtime/astrid","slug":"daemon-returned-an-unexpected-status-response","errorCode":null,"errorMessage":"daemon returned an unexpected status response","messagePattern":"daemon returned an unexpected status response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/doctor.rs","lineNumber":244,"sourceCode":"async fn daemon_roundtrip() -> Result<()> {\n    let mut client = tokio::time::timeout(\n        Duration::from_secs(5),\n        crate::socket_client::connect_kernel_for_workspace(None),\n    )\n    .await\n    .map_err(|_| anyhow::anyhow!(\"connection timed out after 5s\"))??;\n    match tokio::time::timeout(\n        Duration::from_secs(5),\n        client.request(KernelRequest::GetStatus),\n    )\n    .await\n    .map_err(|_| anyhow::anyhow!(\"daemon response timed out after 5s\"))??\n    {\n        KernelResponse::Status(_) => Ok(()),\n        KernelResponse::Error(message) => {\n            Err(anyhow::anyhow!(\"daemon rejected status request: {message}\"))\n        },\n        _ => Err(anyhow::anyhow!(\n            \"daemon returned an unexpected status response\"\n        )),\n    }\n}\n\n/// Query the daemon for agent-loop readiness over the same socket the\n/// other daemon-dependent checks use. Rides the existing\n/// `astrid.v1.request.` ingress allowlist prefix — no capsule change needed.\nasync fn agent_readiness() -> Result<astrid_core::kernel_api::AgentLoopReadiness> {\n    let mut client = tokio::time::timeout(\n        Duration::from_secs(5),\n        crate::socket_client::connect_kernel_for_workspace(None),\n    )\n    .await\n    .map_err(|_| anyhow::anyhow!(\"connection timed out after 5s\"))??;\n    match tokio::time::timeout(\n        Duration::from_secs(5),\n        client.request(KernelRequest::GetAgentReadiness),","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/doctor.rs#L226-L262","documentation":"The doctor command sends a KernelRequest::Status over the daemon socket and matches on the reply. If the daemon replies with any KernelResponse variant other than Status or Error, this anyhow error is thrown. It means the daemon is reachable and answered, but with a response type the doctor's status check does not understand.","triggerScenarios":"Running `astrid doctor`'s daemon_roundtrip check while the daemon (or an intermediary protocol layer) returns an unexpected variant such as AgentReadiness or another non-Status response to a Status request, typically due to a CLI/daemon version mismatch.","commonSituations":"A daemon built from a different commit or older version is still running on the socket after an upgrade; a new CLI sends Status but the old daemon responds with a shape the CLI doesn't map for that request.","solutions":["Restart the daemon so its protocol version matches the CLI binary","Rebuild/reinstall astrid-cli and the daemon from the same source revision","Check for a stale socket file from a previous daemon and remove it before restarting","Add a protocol/version handshake to KernelRequest::Status handling to fail fast on mismatch"],"exampleFix":"// before\nKernelResponse::Status(_) => Ok(()),\n// after\nKernelResponse::Status(_) => Ok(()),\nKernelResponse::Pong => Ok(()), // accept variants a legacy daemon may return","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_status_response(resp: &KernelResponse) -> bool { matches!(resp, KernelResponse::Status(_)) }","tryCatchPattern":"match daemon_roundtrip().await {\n    Ok(()) => { /* healthy */ }\n    Err(e) if e.to_string().contains(\"unexpected status response\") => {\n        // treat as version skew: advise daemon restart\n    }\n    Err(e) => eprintln!(\"doctor failed: {e:#}\"),\n}","preventionTips":["Restart the daemon after every CLI upgrade","Add a protocol version handshake and check it before sending requests","Pin CLI and daemon to the same release version in deployment scripts"],"tags":["daemon","ipc","protocol-mismatch","rust"],"backgroundTag":"unexpected-response-shape","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}