Summarize the newest conversations first: the summary queue runs in directory-listing order

Open Beginner friendly
#218 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
cli

Research direction

Start in src/sync.ts and find where syncConversations builds filesToSummarize before slicing it to summaryLimit. The change should sort the queued files by archived file mtime, newest first, before selecting the first 10 entries. Verify the behavior by running the sync against files with different modification times and confirming that recent conversations are summarized before older ones.

Written by the indexing model from the issue text.

Description

Goal

Recent conversations should get summaries first. A summary helps most on the sessions you're likely to search for next: this week's work, not last summer's. Today a large backlog is summarized in directory-listing order, so the newest sessions are usually the last to get one.

What happens now (1.6.0)

syncConversations (src/sync.ts) builds filesToSummarize as it walks the source directory. For each source it summarizes the first summaryLimit entries (default 10) and leaves the rest for later syncs:

const summaryLimit = options.summaryLimit ?? 10;
const toSummarize = filesToSummarize.slice(0, summaryLimit);

So the queue's order is the walk order:

  • Claude Code: project directories alphabetically (-Users-me-A… before -Users-me-Z…), then files in each one in findJsonlFiles order. One busy project late in the alphabet waits behind every earlier project's backlog.
  • Codex: ~/.codex/sessions/YYYY/MM/DD/, so oldest first. With a backlog, the session you finished an hour ago is the last one summarized.

With a big archive this matters. Mine has about 4,700 transcripts and fewer than 60 summaries. At 10 per source per sync, the backlog takes hundreds of syncs to clear, and newer sessions keep joining the end of the queue.

Proposal

Sort the queue newest first by the archived file's mtime before slicing. Sync already sets the archive copy's mtime to the source's, so mtime tracks the session's last activity:

const summaryMtime = (f) => { try { return fs.statSync(f.path).mtimeMs; } catch { return 0; } };
filesToSummarize.sort((a, b) => summaryMtime(b) - summaryMtime(a));
const toSummarize = filesToSummarize.slice(0, summaryLimit);

That's what I'm running locally, patched into dist/sync.js. The extra stat calls cost little next to a summarizer call, and the sort only covers files already queued. A session that's still live keeps moving to the front, but that already happens through copyIfNewer, and a summary that's out of date at the next sync is no worse than having none.

If newest-first shouldn't be the default for everyone, an env var such as EPISODIC_MEMORY_SUMMARY_ORDER=newest|oldest|walk would work too. I don't see a use for walk order, though.

Related

  • #188: the backlog turning into a nonstop summarizer loop. With newest first, the sessions that matter get summarized early even while the backlog keeps the loop busy.
  • #129: wasted summary quota on sidechain sessions.
  • #204: backfill stalling on one long conversation.

A related source of backlog: a review tool that drives Codex non-interactively (roborev, in my case) leaves one short rollout per review. That's 3,120 of my 3,545 Codex rollouts. They're worth keeping in the index, but they don't need summaries. I'm getting around it by writing the empty -summary.txt sentinel beside them, which relies on internal sentinel behaviour. A supported way to keep a session indexed without summarizing it would be a separate issue, and I'm happy to file it if that's useful.

Dominant language
TypeScript
Stars
511
Forks
154
Avg merge
14d 20h
Merged PRs (30d)
6

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from obra/episodic-memory

All issues in obra/episodic-memory

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.