Skip to content

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

refactor(agent): improve thread history check in background completions

Steven Enamakel3beda16e0765
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
index 74f4754471..9f6bef2a03 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
@@ -543,7 +543,16 @@ pub(crate) fn discard_for_thread(
// in-memory fence. Durable lifecycle markers and settled completion history
// both remain in the store after compaction, so a previously used thread
// still gets a permanent delete marker after a restart.
- let has_history = !entry.store.list(Some(thread_id)).is_empty();
+ let has_history = match entry.store.try_list(Some(thread_id)) {
+ Ok(records) => !records.is_empty(),
+ Err(error) => {
+ log::warn!(
+ "[background_completions] could not inspect thread history before delete \
+ thread_id={thread_id} error={error}"
+ );
+ true
+ }
+ };
let has_legacy_delete_marker = is_marked_deleted(&entry, thread_id);
if !seen && !has_history && !has_legacy_delete_marker {
return 0;