Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

refactor(workstream): name the candidate order of a session lookup

Vinícius DS Andradeeb364ddabe88
diff --git a/crates/ai-memory-workstream/src/transcript.rs b/crates/ai-memory-workstream/src/transcript.rs
index df8eac6a..b9c7492e 100644
--- a/crates/ai-memory-workstream/src/transcript.rs
+++ b/crates/ai-memory-workstream/src/transcript.rs
@@ -2626,9 +2626,8 @@ fn locate_session_file(
}
return Ok(None);
}
- let mut files = collect_session_files(harness, home, session_dir)?;
- files.sort_by_key(|path| temporary_transcript(path));
- for path in files.into_iter().take(2_000) {
+ let files = collect_session_files(harness, home, session_dir)?;
+ for path in lookup_candidates(files) {
if session_path_matches(harness, &path, id, cwd)? {
return Ok(Some(path));
}
@@ -2636,6 +2635,14 @@ fn locate_session_file(
Ok(None)
}
+/// The transcripts a session lookup reads, in the order it reads them.
+/// Temporary copies go last, and the scan stops after a fixed number.
+fn lookup_candidates(mut files: Vec<PathBuf>) -> Vec<PathBuf> {
+ files.sort_by_key(|path| temporary_transcript(path));
+ files.truncate(2_000);
+ files
+}
+
/// The folder Claude Code keeps a project's transcripts in: the cwd with
/// every character outside `[A-Za-z0-9]` replaced by `-`, so `/a/b.c_d` is
/// `-a-b-c-d` and `C:\\Users\\me` is `C--Users-me`.