astrid-runtime/astrid · error

unexpected response from kernel: {other:?}

Error message

unexpected response from kernel: {other:?}

What it means

apply_initial_quotas sends an Admin command (SetPrincipal with principal) to the kernel and expects an AdminResponseBody::Quotas reply. Any other reply variant indicates the kernel responded out of protocol — the request/response pairing broke — and the code bails with a debug-formatted view of the unexpected body. This guards the agent-creation flow (run_create) against silently misapplying quota updates.

Source

Thrown at crates/astrid-cli/src/commands/agent/mod.rs:472

/// Apply the parsed quota deltas: `QuotaGet` to pull the new agent's
/// defaults, replay each requested field, single `QuotaSet`. A failure
/// here leaves the agent in place with default quotas — operator can
/// re-run `astrid quota set -a <name> ...` to retry.
async fn apply_initial_quotas(
    client: &mut AdminClient,
    principal: &PrincipalId,
    updates: &[QuotaField],
) -> Result<()> {
    let body = client
        .request(AdminRequestKind::QuotaGet {
            principal: principal.clone(),
        })
        .await?;
    let body = into_result(body)?;
    let mut quotas = match body {
        AdminResponseBody::Quotas(q) => q,
        other => anyhow::bail!("unexpected response from kernel: {other:?}"),
    };
    for field in updates {
        match field {
            QuotaField::Memory(b) => quotas.max_memory_bytes = *b,
            QuotaField::Timeout(s) => quotas.max_timeout_secs = *s,
            QuotaField::Storage(b) => quotas.max_storage_bytes = *b,
            QuotaField::Processes(n) => quotas.max_background_processes = *n,
        }
    }
    let body = client
        .request(AdminRequestKind::QuotaSet {
            principal: principal.clone(),
            quotas,
        })
        .await?;
    let _ = into_result(body)?;
    println!(
        "  {}",

View on GitHub (pinned to affd8760f4)

Solutions

  1. Check the debug dump ({other:?}) to see which body variant arrived and why.
  2. Align CLI and kernel versions to the same release.
  3. Check kernel logs for the original admin request failure; fix the underlying cause (e.g. invalid quota values, permission problem).
  4. Retry agent creation after the kernel is healthy; if mispairing persists, report a protocol bug.

Example fix

// before
let body = into_result(body)?;
let mut quotas = match body {
    AdminResponseBody::Quotas(q) => q,
    other => anyhow::bail!("unexpected response from kernel: {other:?}"),
};

// after: surface kernel errors properly
let body = into_result(body)?;
let mut quotas = match body {
    AdminResponseBody::Quotas(q) => q,
    AdminResponseBody::Error(e) => anyhow::bail!("kernel rejected quota set: {e:?}"),
    other => anyhow::bail!("unexpected response from kernel: {other:?}"),
};
Defensive patterns

Strategy: type-guard

Validate before calling

// after sending the admin request, verify the variant before use
if !matches!(body, AdminResponseBody::Quotas(_)) {
    eprintln!("kernel did not answer the quotas request: {body:?}");
}

Type guard

fn as_quotas(body: &AdminResponseBody) -> Option<&Quotas> {
    match body {
        AdminResponseBody::Quotas(q) => Some(q),
        _ => None,
    }
}

Try / catch

match run_create(&opts).await {
    Ok(agent) => { /* ... */ }
    Err(e) if e.to_string().contains("unexpected response from kernel") => {
        eprintln!("protocol mismatch; check CLI/kernel versions and kernel logs");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: run_create → apply_initial_quotas when the kernel's reply to the quotas admin request is any AdminResponseBody variant other than Quotas (e.g. an error body, an ack for a different command, or a misrouted response).

Common situations: Kernel version skew with the CLI (different response schema); kernel returning an error-shaped body after a failed quota set; a concurrency/multiplexing bug pairing responses with the wrong requests; hitting a kernel that doesn't implement the quotas admin command.

Related errors


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