Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: I don't see a diff in your message — the "Diff:" section is empty, and the stat is blank to

Steven Enamakeld58596d5b721
diff --git a/crates/openhuman-core/src/profiles/recovery.rs b/crates/openhuman-core/src/profiles/recovery.rs
index fa4a2df5ad..688bf76a5d 100644
--- a/crates/openhuman-core/src/profiles/recovery.rs
+++ b/crates/openhuman-core/src/profiles/recovery.rs
@@ -8,11 +8,12 @@ use std::sync::Arc;
use super::types::ProfileId;
use crate::core::runtime::CoreContext;
-/// Settle what a previous holder left in profile `id`'s workspace: turns that
-/// were mid-flight become interrupted and run-ledger rows left running are
-/// closed. The sweep a single-user core runs at boot, run when a profile's
-/// lease is taken over from a holder that never released it. Failures are
-/// logged; the profile still opens.
+/// Settle what a previous holder left in profile `id`'s workspace: turn-state
+/// files that were mid-flight become interrupted. The run ledger and the
+/// stored turn states live in the storage backend and are swept by
+/// [`recover_session_store`]. Run when a profile's lease is taken over from a
+/// holder that never released it. Failures are logged; the profile still
+/// opens.
pub(crate) fn recover_workspace(id: &ProfileId, workspace_dir: &std::path::Path) {
let now = chrono::Utc::now().to_rfc3339();
match tinyagents_session::turn_state::store::mark_all_interrupted(
@@ -23,17 +24,6 @@ pub(crate) fn recover_workspace(id: &ProfileId, workspace_dir: &std::path::Path)
Ok(turns) => log::info!("[profiles] profile={id} recovered {turns} interrupted turn(s)"),
Err(error) => log::warn!("[profiles] profile={id} turn recovery failed: {error}"),
}
- if crate::storage::installed_is_shared() {
- // Another replica may still be driving a run in a shared backend.
- return;
- }
- match crate::agent::session_store::with_ledger(workspace_dir, |ledger| async move {
- ledger.interrupt_orphaned_agent_runs().await
- }) {
- Ok(0) => {}
- Ok(runs) => log::info!("[profiles] profile={id} settled {runs} orphaned run(s)"),
- Err(error) => log::warn!("[profiles] profile={id} run recovery failed: {error:#}"),
- }
}
/// [`recover_workspace`] for turn states kept in a storage-backed session
@@ -60,4 +50,27 @@ pub(crate) fn recover_session_store(id: &ProfileId, context: &Arc<CoreContext>)
}
Err(error) => log::warn!("[profiles] profile={id} stored turn recovery failed: {error}"),
}
+ if crate::storage::installed_is_shared() {
+ // Another replica may still be driving a run in a shared backend.
+ return;
+ }
+ match provider.run_ledger_for_agent(&key) {
+ Ok(Some(ledger)) => {
+ let swept = crate::storage::block_on(async move {
+ Ok(ledger.interrupt_orphaned_agent_runs().await)
+ });
+ match swept {
+ Ok(Ok(0)) => {}
+ Ok(Ok(runs)) => {
+ log::info!("[profiles] profile={id} settled {runs} orphaned run(s)");
+ }
+ Ok(Err(error)) => {
+ log::warn!("[profiles] profile={id} run recovery failed: {error:#}");
+ }
+ Err(error) => log::warn!("[profiles] profile={id} run recovery failed: {error}"),
+ }
+ }
+ Ok(None) => {}
+ Err(error) => log::warn!("[profiles] profile={id} run ledger unavailable: {error}"),
+ }
}