Skip to content

Commit 0500d89

Browse files
Add compaction+sessionFs test
1 parent c31320c commit 0500d89

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

nodejs/test/e2e/session_fs.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------------------------------------------*/
44

5+
import { SessionCompactionCompleteEvent } from "@github/copilot/sdk";
56
import { MemoryProvider, VirtualProvider } from "@platformatic/vfs";
67
import { describe, expect, it, onTestFinished } from "vitest";
78
import { CopilotClient } from "../../src/client.js";
@@ -124,6 +125,26 @@ describe("Session Fs", async () => {
124125
const fileContent = await provider.readFile(p(session.sessionId, filename!), "utf8");
125126
expect(fileContent).toBe(suppliedFileContent);
126127
});
128+
129+
it("should succeed with compaction while using sessionFs", async () => {
130+
const session = await client.createSession({
131+
onPermissionRequest: approveAll,
132+
createSessionFsHandler,
133+
});
134+
135+
let compactionEvent: SessionCompactionCompleteEvent | undefined;
136+
session.on("session.compaction_complete", (evt) => (compactionEvent = evt));
137+
138+
await session.sendAndWait({ prompt: "What is 2+2?" });
139+
140+
const eventsPath = p(session.sessionId, "/session-state/events.jsonl");
141+
await expect.poll(() => provider.exists(eventsPath)).toBe(true);
142+
143+
await session.rpc.compaction.compact();
144+
await expect.poll(() => compactionEvent).toBeDefined();
145+
expect(compactionEvent!.data.success).toBe(true);
146+
expect(compactionEvent!.data.summaryContent).toContain("<overview>");
147+
});
127148
});
128149

129150
function findToolCallResult(messages: SessionEvent[], toolName: string): string | undefined {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
models:
2+
- claude-sonnet-4.5
3+
conversations:
4+
- messages:
5+
- role: system
6+
content: ${system}
7+
- role: user
8+
content: What is 2+2?
9+
- role: assistant
10+
content: 2 + 2 = 4
11+
- role: user
12+
content: ${compaction_prompt}
13+
- role: assistant
14+
content: >-
15+
<overview>
16+
17+
The user asked a simple arithmetic question ("What is 2+2?"). This was a minimal interaction with no technical
18+
work, coding tasks, or file modifications requested or performed. The conversation consisted solely of
19+
providing a basic mathematical answer.
20+
21+
</overview>
22+
23+
24+
<history>
25+
26+
1. The user asked "What is 2+2?"
27+
- Provided the answer: 4
28+
- No further requests or actions were needed
29+
30+
2. The user requested a checkpoint summary
31+
- Creating this summary to preserve conversation context before history compaction
32+
</history>
33+
34+
35+
<work_done>
36+
37+
No files were created, modified, or deleted. No technical work was performed. The conversation consisted only
38+
of answering a simple arithmetic question.
39+
40+
41+
Current state:
42+
43+
- No active tasks
44+
45+
- No code changes
46+
47+
- No systems or processes started
48+
49+
</work_done>
50+
51+
52+
<technical_details>
53+
54+
No technical work was performed during this conversation. No technical decisions, issues, or discoveries were
55+
made.
56+
57+
</technical_details>
58+
59+
60+
<important_files>
61+
62+
No files are relevant to this conversation, as no technical work was performed.
63+
64+
</important_files>
65+
66+
67+
<next_steps>
68+
69+
No pending work or next steps. The user's request (answering "2+2") has been completed. Awaiting further
70+
instructions from the user.
71+
72+
</next_steps>
73+
74+
75+
<checkpoint_title>Simple arithmetic question answered</checkpoint_title>

0 commit comments

Comments
 (0)