astrid-runtime/astrid · error

unexpected daemon response: {other:?}

Error message

unexpected daemon response: {other:?}

What it means

In capsule show's run, any daemon reply to GetCapsuleMetadata that is neither CapsuleMetadata(entries) nor Error(message) causes this bail with the response's debug representation. It indicates the daemon sent a recognized KernelResponse variant that does not fit the request — a protocol/schema mismatch between CLI and daemon. The debug output helps diagnose which variant arrived.

Source

Thrown at crates/astrid-cli/src/commands/capsule/show.rs:74

    /// `not-pinned`.
    pub contracts_status: String,
    /// Verbatim `Capsule.toml` body.
    pub manifest: String,
    /// Human-facing permissions derived from the manifest.
    pub permissions: Vec<SemanticCapability>,
}

/// Entry point for `astrid capsule show`.
pub(crate) async fn run(args: &ShowArgs) -> Result<ExitCode> {
    let principal = context::resolve_agent(args.agent.as_deref())?;
    let format = ValueFormat::parse(&args.format);
    let mut client = crate::socket_client::connect_kernel_for_workspace(None).await?;
    let entries = match client.request(KernelRequest::GetCapsuleMetadata).await? {
        KernelResponse::CapsuleMetadata(entries) => entries,
        KernelResponse::Error(message) => {
            anyhow::bail!("daemon rejected capsule metadata request: {message}")
        },
        other => anyhow::bail!("unexpected daemon response: {other:?}"),
    };
    let Some(entry) = entries.into_iter().find(|entry| entry.name == args.name) else {
        eprintln!(
            "{}",
            Theme::error(&format!(
                "capsule '{}' is not installed for agent '{principal}'",
                args.name
            ))
        );
        return Ok(ExitCode::from(1));
    };
    let capabilities: astrid_capsule_types::manifest::CapabilitiesDef =
        serde_json::from_value(entry.capabilities.clone())?;
    let permissions = semantic_capabilities(&capabilities);
    let manifest = serde_json::to_string_pretty(&serde_json::json!({
        "package": {
            "name": entry.name,
            "version": entry.version,

View on GitHub (pinned to affd8760f4)

Solutions

  1. Align CLI and daemon versions (restart the daemon from the same release as the CLI) and retry.
  2. Inspect the printed response variant in the error to identify the mismatch.
  3. Check for topic/correlation-id routing bugs if you run multiple CLI sessions against one daemon.
Defensive patterns

Strategy: type-guard

Validate before calling

// verify request/response schema version before sending
if daemon_protocol_version()? != expected_protocol_version() {
    anyhow::bail!("daemon/CLI protocol mismatch — restart daemon");
}

Type guard

fn as_metadata(resp: &KernelResponse) -> Option<&Vec<CapsuleEntry>> {
    if let KernelResponse::CapsuleMetadata(e) = resp { Some(e) } else { None }
}

Try / catch

match client.request(KernelRequest::GetCapsuleMetadata).await? {
    KernelResponse::CapsuleMetadata(e) => Ok(e),
    other => {
        // debug-print variant, restart daemon on version drift
        Err(anyhow!("unexpected: {other:?}"))
    }
}

Prevention

When it happens

Trigger: astrid capsule show receives e.g. KernelResponse::Success(..) or an unrelated variant where CapsuleMetadata was expected — typically a daemon built from different versions or a routing mix-up on the response topic.

Common situations: CLI upgraded without restarting an old daemon (or vice versa); a proxy/broker delivering another request's response; custom daemon builds replying with Success instead of CapsuleMetadata.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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