diff options
| author | Adam Malczewski <[email protected]> | 2026-06-22 01:22:21 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-22 01:22:21 +0900 |
| commit | ae8f61cefd383417bc0f80447d7ab1bfdfe0726d (patch) | |
| tree | ddb6ccb08a4338aa2c6ccb397696074d8c2c22c5 /packages/session-orchestrator/src | |
| parent | 54613fc2bd4869a95ffda34230006da6d9dfc8c3 (diff) | |
| download | dispatch-ae8f61cefd383417bc0f80447d7ab1bfdfe0726d.tar.gz dispatch-ae8f61cefd383417bc0f80447d7ab1bfdfe0726d.zip | |
fix: compaction keeps original ID, forks old history to archive, chains via compactedFrom
Reworked compaction to match the confirmed design:
- The compacted conversation KEEPS its original ID (messaging between
agents is unaffected — the ID never changes)
- The old full history is forked to a new archive conversation (new UUID)
- The archive inherits the source's compactedFrom, creating a chain:
A → Y → X (walk compactedFrom backward)
- A's history is replaced with [summary + recent N]
- A.compactedFrom = archive ID
forkHistory: inherit compactedFrom from source (not set to sourceId),
so archives chain backward to previous archives.
FE: no tab switching needed — the ID doesn't change. Just reload history.
Diffstat (limited to 'packages/session-orchestrator/src')
| -rw-r--r-- | packages/session-orchestrator/src/orchestrator.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/packages/session-orchestrator/src/orchestrator.ts b/packages/session-orchestrator/src/orchestrator.ts index 21c068c..b46ecc1 100644 --- a/packages/session-orchestrator/src/orchestrator.ts +++ b/packages/session-orchestrator/src/orchestrator.ts @@ -132,7 +132,7 @@ export const conversationStatusChanged: EventHookDescriptor<ConversationStatusCh /** Payload for the conversationCompacted bus event. */ export interface ConversationCompactedPayload { readonly conversationId: string; - readonly archiveId: string; + readonly newConversationId: string; readonly messagesSummarized: number; readonly messagesKept: number; } @@ -802,8 +802,11 @@ export function createCompactionService( return { error: "model produced empty summary" }; } - // Non-destructive: fork the full pre-compaction history to an - // archive conversation before replacing it. + // Non-destructive: fork the full pre-compaction history to a new + // archive conversation. The original conversation keeps its ID + // (so messaging between agents still works) and gets the compacted + // content. The archive inherits the original's compactedFrom, + // creating a chain: A → Y → X → ... const archiveId = crypto.randomUUID(); await deps.conversationStore.forkHistory(conversationId, archiveId); @@ -823,14 +826,14 @@ export function createCompactionService( const result: CompactionResult = { summary, - archiveId, + newConversationId: archiveId, messagesSummarized: toSummarize.length, messagesKept: toKeep.length, }; deps.emit(conversationCompacted, { conversationId, - archiveId, + newConversationId: archiveId, messagesSummarized: toSummarize.length, messagesKept: toKeep.length, }); |
