tinyhumansai/openhuman · error

learning_update_facet: upsert failed

Error message

learning_update_facet: upsert failed: {e:#}

What it means

The facet was found and modified, but persisting it back through cache upsert failed — a memory-driver write error. The in-memory view changed while the durable facet store rejected the write, so the update is not guaranteed to have stuck.

Solutions

  1. Retry the update_facet call — re-reading gets the fresh state first
  2. Check memory module/store health if upserts persistently fail
  3. Verify with learning_get_facet afterwards whether the write landed
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/openhuman/agent/learning/tools.rs:263 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/8ae967f02bb9392b. Report an issue: GitHub.

Appendix: source

Thrown at src/openhuman/agent/learning/tools.rs:263

    async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
        log::debug!("[tool][learning] update_facet invoked");
        let class_str = read_required_str(&args, "class")?;
        let key_suffix = read_required_str(&args, "key")?;
        let value = read_required_str(&args, "value")?;
        let fk = full_key(&class_str, &key_suffix);
        let cache = get_cache().await?;
        let mut facet = cache
            .get(&fk)
            .await
            .map_err(|e| anyhow::anyhow!("learning_update_facet: {e:#}"))?
            .ok_or_else(|| anyhow::anyhow!("learning_update_facet: facet not found: {fk}"))?;
        facet.value = value;
        facet.user_state = UserState::Pinned;
        cache
            .upsert(&facet)
            .await
            .map_err(|e| anyhow::anyhow!("learning_update_facet: upsert failed: {e:#}"))?;
        Ok(ToolResult::success(serde_json::to_string(&json!({
            "facet": facet_to_json(&facet),
        }))?))
    }
}

/// Set/clear a facet's pin via `set_user_state`. Shared by pin/unpin.
async fn set_pin(
    args: serde_json::Value,
    tool: &str,
    state: UserState,
) -> anyhow::Result<ToolResult> {
    let class_str = read_required_str(&args, "class")?;
    let key_suffix = read_required_str(&args, "key")?;
    let fk = full_key(&class_str, &key_suffix);
    let cache = get_cache().await?;
    let updated = cache
        .set_user_state(&fk, state)

View on GitHub (pinned to 7491200858)