Skip to content

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

fix: continue conversation repair past unreadable threads

Steven Enamakel8c0cfc4b52fa
diff --git a/src/openhuman/memory/conversations/store/store_concurrency_tests.rs b/src/openhuman/memory/conversations/store/store_concurrency_tests.rs
index 22cdc6f36b..b4fa6ad2fd 100644
--- a/src/openhuman/memory/conversations/store/store_concurrency_tests.rs
+++ b/src/openhuman/memory/conversations/store/store_concurrency_tests.rs
@@ -57,3 +57,48 @@ fn one_hundred_agent_threads_append_without_loss_or_corruption() {
assert_eq!(messages[0].id, format!("message-{index}"));
}
}
+
+#[test]
+fn one_unreadable_transcript_does_not_stop_other_repairs() {
+ let temp = TempDir::new().unwrap();
+ let store = ConversationStore::new(temp.path().to_path_buf());
+ let created_at = "2026-09-10T00:00:00Z".to_string();
+
+ for id in ["a-unreadable", "z-readable"] {
+ store
+ .ensure_thread(CreateConversationThread {
+ parent_thread_id: None,
+ id: id.to_string(),
+ title: id.to_string(),
+ created_at: created_at.clone(),
+ labels: None,
+ personality_id: None,
+ })
+ .unwrap();
+ }
+
+ std::fs::create_dir_all(store.thread_messages_path("a-unreadable")).unwrap();
+ append_jsonl(
+ &store.thread_messages_path("z-readable"),
+ &ConversationMessage {
+ id: "message".to_string(),
+ content: "recover me".to_string(),
+ message_type: "text".to_string(),
+ extra_metadata: serde_json::json!({}),
+ sender: "assistant".to_string(),
+ created_at,
+ },
+ )
+ .unwrap();
+
+ let threads = store.list_threads().unwrap();
+ let readable = threads
+ .iter()
+ .find(|thread| thread.id == "z-readable")
+ .unwrap();
+ assert_eq!(readable.message_count, 1);
+
+ let folded = store.thread_index_unlocked().unwrap();
+ assert_eq!(folded["z-readable"].message_count, Some(1));
+ assert_eq!(folded["a-unreadable"].message_count, None);
+}
diff --git a/src/openhuman/memory/conversations/store/store_index.rs b/src/openhuman/memory/conversations/store/store_index.rs
index 75e0747482..91e863b912 100644
--- a/src/openhuman/memory/conversations/store/store_index.rs
+++ b/src/openhuman/memory/conversations/store/store_index.rs
@@ -4,7 +4,7 @@
//! API in `store_ops.rs` (and the unit tests) can call it, but it stays out of
//! the crate's public surface.
-use std::collections::BTreeMap;
+use std::collections::{BTreeMap, HashSet};
use std::fs::{self, File};
use std::path::PathBuf;
@@ -180,6 +180,7 @@ impl ConversationStore {
/// metadata; a newly-created thread discovered between passes is handled
/// by the next iteration.
pub(super) fn list_threads_coordinated(&self) -> Result<Vec<ConversationThread>, String> {
+ let mut unreadable = HashSet::new();
loop {
let (index, missing) = {
let _metadata = self.locks.metadata.lock();
@@ -189,6 +190,7 @@ impl ConversationStore {
.filter(|(_, entry)| {
entry.message_count.is_none() || entry.last_message_at.is_none()
})
+ .filter(|(thread_id, _)| !unreadable.contains(*thread_id))
.map(|(thread_id, _)| thread_id.clone())
.collect::<Vec<_>>();
(index, missing)
@@ -210,9 +212,11 @@ impl ConversationStore {
}
let Ok((count, last_message_at)) = self.measure_messages_unlocked(&thread_id)
else {
- // One unreadable transcript must not make navigation
- // unavailable or cause an unbounded retry loop.
- return Ok(Self::threads_from_index(index));
+ // Quarantine this thread for this invocation so it neither
+ // blocks repairs for later threads nor causes the outer
+ // loop to retry it forever. A future list call retries it.
+ unreadable.insert(thread_id);
+ continue;
};
let resolved_last = last_message_at.unwrap_or_else(|| entry.created_at.clone());
append_jsonl(