tinyhumansai/openhuman · error · anyhow::Error

failed to serialize {action} response: {e}

Error message

failed to serialize {action} response: {e}

What it means

Wrapped error in the tiny.place tool result helpers: an SDK response succeeded but could not be serialized (serde_json) for return to the LLM. Per the helper's docs this is propagated rather than hidden — a response that fails to serialize is a real bug or an unexpected wire shape.

Source

Thrown at src/openhuman/tinyplace/agent_tools/common.rs:381

pub fn sdk_error(action: &str, err: tinyplace::Error) -> ToolResult {
    err_md(sdk_error_text(action, err))
}

/// Convenience: turn an SDK `Result` into `anyhow::Result<Value>`, rendering
/// the error as markdown carried in the `anyhow` message (the FlowTool surfaces
/// it to the LLM verbatim).
///
/// Serialization errors are **propagated**, not hidden: a response that fails to
/// deserialize is a real bug worth surfacing. Callers hitting endpoints that
/// return `null` for an *empty* collection should use [`list_or_empty`] instead,
/// which degrades only that specific case.
pub fn val_or_err<T: serde::Serialize>(
    action: &str,
    result: tinyplace::Result<T>,
) -> anyhow::Result<Value> {
    match result {
        Ok(v) => serde_json::to_value(v)
            .map_err(|e| anyhow::anyhow!("failed to serialize {action} response: {e}")),
        Err(e) => Err(anyhow::anyhow!("{}", sdk_error_text(action, e))),
    }
}

/// Like [`val_or_err`], but for the narrow set of SDK calls whose backend
/// returns `null` for an empty collection (`{"messages": null}`, empty
/// submissions) — which the typed SDK surfaces as a `Serialization` error.
/// Degrades **only** that case to an empty array; every other error, including a
/// genuine shape mismatch, is still surfaced. Mirrors the `*_degrade` handling
/// in the internal controllers, scoped to the endpoints that actually need it.
pub fn list_or_empty<T: serde::Serialize>(
    action: &str,
    result: tinyplace::Result<T>,
) -> anyhow::Result<Value> {
    match result {
        Ok(v) => serde_json::to_value(v)
            .map_err(|e| anyhow::anyhow!("failed to serialize {action} response: {e}")),
        Err(e) if is_empty_state(&e) => Ok(Value::Array(Vec::new())),

View on GitHub (pinned to 7491200858)

Solutions

  1. Check {e} for the serde detail naming the unserializable field
  2. Compare the SDK response type against its serde attributes
  3. Report as a bug if the SDK type genuinely cannot serialize
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/openhuman/tinyplace/agent_tools/common.rs:381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/0d2097fa3e03303d. Report an issue: GitHub.