{"record":{"id":"ba90d1294f68cdce","repo":"jdx/mise","slug":"cache-agent-returned-an-unexpected-action-predicti","errorCode":null,"errorMessage":"cache agent returned an unexpected action prediction response","messagePattern":"cache agent returned an unexpected action prediction response","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/cache/rustc.rs","lineNumber":142,"sourceCode":") -> Result<Option<CachedCompilation>> {\n    let task = std::env::var(session::TASK_ENV)\n        .wrap_err_with(|| format!(\"{} is not set\", session::TASK_ENV))?;\n    let mut context = base_action_context(rustc, working_dir)?;\n    let invocation_digest = invocation.invocation_digest(&context)?;\n    let responses = session::request_agent(&[AgentRequest::FindActionPrediction {\n        task,\n        invocation: invocation_digest.clone(),\n    }])?;\n    let Some(response) = responses.into_iter().next() else {\n        bail!(\"cache agent did not return an action prediction response\");\n    };\n    let prediction = match response {\n        AgentResponse::ActionPrediction {\n            prediction: Some(prediction),\n        } => prediction,\n        AgentResponse::ActionPrediction { prediction: None } => return Ok(None),\n        AgentResponse::Error { message } => bail!(message),\n        _ => bail!(\"cache agent returned an unexpected action prediction response\"),\n    };\n    if prediction.adapter != \"rustc\" || prediction.invocation != invocation_digest {\n        bail!(\"cache agent returned an incompatible rustc action prediction\");\n    }\n    let input_prediction: RustcInputPrediction = serde_json::from_str(&prediction.payload)?;\n    if String::from_utf8(canonical_json(&input_prediction)?)? != prediction.payload {\n        bail!(\"cache agent returned a non-canonical rustc action prediction\");\n    }\n    let discovered = input_prediction.discover(working_dir, &context.path_mappings)?;\n    discovered.clone().apply_to(&mut context)?;\n    let action = invocation.action(context)?;\n    let restored = restore_result(&action, outputs, &discovered, restore_outputs)?;\n    if restored.is_some() {\n        record_prediction_value(invocation_digest, action.digest.clone(), prediction.payload);\n    }\n    Ok(restored)\n}\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/cache/rustc.rs#L124-L160","documentation":"After receiving a response to FindActionPrediction, the wrapper matches on the AgentResponse variant: ActionPrediction, or Error. Any other variant (e.g. a Blob or ActionResult reply) means the agent answered a different question than was asked — a protocol violation that bails immediately (src/cache/rustc.rs:142).","triggerScenarios":"A version-skewed or buggy cache agent that mis-routes responses (returns ActionResult/Blob for a prediction request); response/request reordering across a mismatched protocol version.","commonSituations":"Two mise versions on one machine (shim vs direct path) with a shared agent socket; concurrent builds hitting an agent that got upgraded mid-flight.","solutions":["Ensure a single mise version is in play: mise where / which mise, and restart the cache agent and all shells","Re-run the build in a fresh session so wrapper and agent restart together","Disable the rustc cache wrapper if the mismatch persists, and file an issue with the response variant you saw"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"# Treat variant-mismatch as environment breakage: reset session and retry once\nif ! cargo build 2>&1 | tee log | grep -q 'unexpected action prediction response'; then :; else\n  pkill -f mise-cache-agent || true; unset MISE_CACHE_SOCKET MISE_CACHE_TASK; cargo build\nfi","preventionTips":["Use one mise version for the agent and all shells","Restart the agent after mise upgrades before large builds","Report reproducible variant mismatches upstream"],"tags":["mise","rustc-cache","cache-agent","protocol","version-mismatch"],"backgroundTag":"cache-agent-protocol-error","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}