From 1dac099022e764c0d400495597f688f7224ac2ee Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 5 Jul 2026 23:35:53 +0200 Subject: [PATCH] fix(agent): derive short session entry ids from the uuidv7 random tail (closes #6242) The uuidv7 prefix is timestamp-derived and nearly constant between calls, so slicing the first 8 chars degenerated short ids to full-UUID fallbacks. Regression from 80c918c2 which replaced randomUUID with uuidv7. --- packages/agent/CHANGELOG.md | 1 + packages/agent/src/harness/session/jsonl-storage.ts | 4 +++- packages/agent/src/harness/session/memory-storage.ts | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/agent/CHANGELOG.md b/packages/agent/CHANGELOG.md index fb693ad8..21ea92bd 100644 --- a/packages/agent/CHANGELOG.md +++ b/packages/agent/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - Fixed harness split-turn compaction to serialize summary requests so single-concurrency providers are not asked to run overlapping generations ([#5536](https://github.com/earendil-works/pi/issues/5536)). +- Fixed harness session storage short entry ids to use the random tail of the generated uuidv7 instead of the timestamp prefix, which was nearly constant between calls ([#6242](https://github.com/earendil-works/pi/issues/6242)). ## [0.80.3] - 2026-06-30 diff --git a/packages/agent/src/harness/session/jsonl-storage.ts b/packages/agent/src/harness/session/jsonl-storage.ts index 4091a436..912673ff 100644 --- a/packages/agent/src/harness/session/jsonl-storage.ts +++ b/packages/agent/src/harness/session/jsonl-storage.ts @@ -34,7 +34,9 @@ function buildLabelsById(entries: SessionTreeEntry[]): Map { function generateEntryId(byId: { has(id: string): boolean }): string { for (let i = 0; i < 100; i++) { - const id = uuidv7().slice(0, 8); + // The uuidv7 prefix is timestamp-derived and nearly constant between calls, + // so short ids must come from the random tail. + const id = uuidv7().slice(-8); if (!byId.has(id)) return id; } return uuidv7(); diff --git a/packages/agent/src/harness/session/memory-storage.ts b/packages/agent/src/harness/session/memory-storage.ts index c6428cac..fba55dae 100644 --- a/packages/agent/src/harness/session/memory-storage.ts +++ b/packages/agent/src/harness/session/memory-storage.ts @@ -27,7 +27,9 @@ function buildLabelsById(entries: SessionTreeEntry[]): Map { function generateEntryId(byId: { has(id: string): boolean }): string { for (let i = 0; i < 100; i++) { - const id = uuidv7().slice(0, 8); + // The uuidv7 prefix is timestamp-derived and nearly constant between calls, + // so short ids must come from the random tail. + const id = uuidv7().slice(-8); if (!byId.has(id)) return id; } return uuidv7();