astrid-runtime/astrid · error

unexpected response from kernel: {other:?}

Error message

unexpected response from kernel: {other:?}

What it means

In `fetch_summary` (crates/astrid-cli/src/commands/caps.rs:183), the CLI requests AdminRequestKind::AgentList and expects AdminResponseBody::AgentList back; any other variant triggers bail! with the body dump. This helper backs `caps show`, so a mismatched kernel reply prevents looking up the target agent's summary.

Source

Thrown at crates/astrid-cli/src/commands/caps.rs:183

impl From<AgentSummary> for CapsRecord {
    fn from(s: AgentSummary) -> Self {
        Self {
            principal: s.principal.to_string(),
            groups: s.groups,
            grants: s.grants,
            revokes: s.revokes,
        }
    }
}

async fn fetch_summary(target: &PrincipalId) -> Result<AgentSummary> {
    let mut client = crate::admin_client::connect_as_active_agent().await?;
    let body = client.request(AdminRequestKind::AgentList).await?;
    let body = into_result(body)?;
    let agents = match body {
        AdminResponseBody::AgentList(list) => list,
        other => anyhow::bail!("unexpected response from kernel: {other:?}"),
    };
    agents
        .into_iter()
        .find(|a| a.principal == *target)
        .with_context(|| format!("agent '{target}' not found"))
}

async fn run_show(args: ShowArgs) -> Result<ExitCode> {
    let target = context::resolve_agent(args.name.as_deref())?;
    let format = ValueFormat::parse(&args.format);
    let summary = fetch_summary(&target).await?;

    if !format.is_pretty() {
        let record: CapsRecord = summary.into();
        emit_structured(&record, format)?;
        return Ok(ExitCode::SUCCESS);
    }

View on GitHub (pinned to affd8760f4)

Solutions

  1. Deploy matching CLI and kernel versions so the AgentList contract matches
  2. Read the {other:?} dump in the error to identify the actual response variant
  3. Verify connect_as_active_agent targets the kernel that implements AgentList
  4. Check the shared protocol crate for recent AdminResponseBody changes and rebuild the CLI if needed

Example fix

// before
let agents = match body {
    AdminResponseBody::AgentList(list) => list,
    other => anyhow::bail!("unexpected response from kernel: {other:?}"),
};
// after
let AdminResponseBody::AgentList(list) = body else {
    anyhow::bail!("kernel returned non-AgentList body; align CLI and kernel versions");
};
let agents = list;
Defensive patterns

Strategy: type-guard

Validate before calling

// Pre-flight: verify target principal format before calling fetch_summary.
if target.as_str().is_empty() {
    eprintln!("target principal is required");
    return Ok(ExitCode::from(64));
}

Type guard

fn as_agent_list(body: AdminResponseBody) -> Option<Vec<AgentSummary>> {
    match body {
        AdminResponseBody::AgentList(list) => Some(list),
        _ => None,
    }
}

Try / catch

match fetch_summary(&target).await {
    Ok(summary) => use(summary),
    Err(e) if e.to_string().contains("unexpected response from kernel") => {
        eprintln!("caps show failed: {e:#}\nhint: align CLI and kernel versions");
        ExitCode::from(2)
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: The AgentList admin request resolves to a non-AgentList AdminResponseBody variant — kernel/CLI protocol version skew, kernel answering with an error or status body, or a mis-routed/interleaved admin reply.

Common situations: Mixed-version deployment after a kernel upgrade; admin connection to the wrong service; kernel-side change repurposing or renaming the AgentList response variant.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/47736e804bb1bd6a. Report an issue: GitHub.