Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions packages/acp-bridge/src/compactionEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,36 @@ describe('TurnBoundaryCompactionEngine', () => {
expect(data.update.content.text).toBe('How are you?');
expect(snap.compactedTurns[0]!.id).toBe(1);
});

it('keeps promptId and originatorClientId on merged text chunks', () => {
const engine = new TurnBoundaryCompactionEngine();
engine.ingest({
...makeTextChunk(1, 'Hello'),
promptId: 'prompt-1',
originatorClientId: 'client-a',
});
engine.ingest({
...makeTextChunk(2, ' world'),
promptId: 'prompt-1',
originatorClientId: 'client-a',
});
engine.ingest(makeTurnComplete(3));

const textEvent = engine.snapshot().compactedTurns[0]!;
expect(textEvent.promptId).toBe('prompt-1');
expect(textEvent.originatorClientId).toBe('client-a');
});

it('omits attribution on merged chunks whose sources carried none', () => {
const engine = new TurnBoundaryCompactionEngine();
engine.ingest(makeTextChunk(1, 'Hello'));
engine.ingest(makeTextChunk(2, ' world'));
engine.ingest(makeTurnComplete(3));

const textEvent = engine.snapshot().compactedTurns[0]!;
expect(textEvent.promptId).toBeUndefined();
expect(textEvent.originatorClientId).toBeUndefined();
});
});

describe('tool call folding', () => {
Expand Down Expand Up @@ -365,6 +395,25 @@ describe('TurnBoundaryCompactionEngine', () => {
(toolEvents[1]!.data as { update: { title: string } }).update.title,
).toBe('Tool B');
});

it('keeps promptId and originatorClientId on folded tool calls', () => {
const engine = new TurnBoundaryCompactionEngine();
engine.ingest({
...makeToolCall(1, 'tc1', 'running', { title: 'Read file' }),
promptId: 'prompt-1',
originatorClientId: 'client-a',
});
engine.ingest({
...makeToolCallUpdate(2, 'tc1', 'done', { rawOutput: 'contents' }),
promptId: 'prompt-1',
originatorClientId: 'client-a',
});
engine.ingest(makeTurnComplete(3));

const toolEvent = engine.snapshot().compactedTurns[0]!;
expect(toolEvent.promptId).toBe('prompt-1');
expect(toolEvent.originatorClientId).toBe('client-a');
});
});

describe('text segmentation across tool calls', () => {
Expand Down
Loading