tinyhumansai/openhuman · error

Failed to stage temp file for {file}: {e}

Error message

Failed to stage temp file for {file}: {e}

What it means

Writing the sibling temp file (.{file}.{pid}.{seq}.tmp) for the atomic replace of MEMORY.md failed with the filesystem error {e}. The original file is untouched — the tool cleans up the partial temp file and aborts before the rename.

Source

Thrown at src/openhuman/tools/impl/filesystem/update_memory_md.rs:122

    let dir = path
        .parent()
        .ok_or_else(|| anyhow::anyhow!("target path has no parent directory"))?;
    let seq = TEMP_FILE_SEQ.fetch_add(1, Ordering::Relaxed);
    let tmp_name = format!(".{file}.{}.{seq}.tmp", std::process::id());
    let tmp_path = dir.join(tmp_name);

    tracing::debug!(
        tmp = %tmp_path.display(),
        target = %path.display(),
        bytes = content.len(),
        "[update_memory_md] atomic write: staging temp file"
    );

    if let Err(e) = tokio::fs::write(&tmp_path, content).await {
        // Clean up a partially-written temp file so a failed stage doesn't
        // litter the workspace (CodeRabbit: temp not cleaned on initial write).
        let _ = tokio::fs::remove_file(&tmp_path).await;
        return Err(anyhow::anyhow!("Failed to stage temp file for {file}: {e}"));
    }

    if let Err(e) = tokio::fs::rename(&tmp_path, path).await {
        // Best-effort cleanup so a failed rename doesn't litter the workspace.
        let _ = tokio::fs::remove_file(&tmp_path).await;
        return Err(anyhow::anyhow!("Failed to atomically write {file}: {e}"));
    }

    tracing::debug!(
        target = %path.display(),
        "[update_memory_md] atomic write: rename committed"
    );
    Ok(())
}

/// Appends or replaces a named section in MEMORY.md or SKILL.md.
///
/// Supports two actions:

View on GitHub (pinned to 7491200858)

Solutions

  1. Read {e} for the OS cause (disk full, permissions)
  2. Free space or fix permissions in the workspace directory
  3. Retry once the underlying condition is cleared
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/openhuman/tools/impl/filesystem/update_memory_md.rs:122 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/621625e7abe22a0b. Report an issue: GitHub.