Skip to content

Commit 241b8d8

Browse files
Fix test isolation: use sendAndWait in blob/attachment tests
The blob and file attachment tests used session.send() (fire-and-forget) then immediately disconnected. The pending CAPI request leaked into subsequent tests via the shared CLI process, causing the vision test's proxy to receive mismatched requests. Use sendAndWait to ensure the CLI finishes processing before the test completes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent be073f2 commit 241b8d8

File tree

3 files changed

+149
-5
lines changed

3 files changed

+149
-5
lines changed

nodejs/test/e2e/session_config.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("Session Configuration", async () => {
4646
it("should accept blob attachments", async () => {
4747
const session = await client.createSession({ onPermissionRequest: approveAll });
4848

49-
await session.send({
49+
await session.sendAndWait({
5050
prompt: "Describe this image",
5151
attachments: [
5252
{
@@ -58,7 +58,6 @@ describe("Session Configuration", async () => {
5858
],
5959
});
6060

61-
// Just verify send doesn't throw — blob attachment support varies by runtime
6261
await session.disconnect();
6362
});
6463

@@ -67,12 +66,11 @@ describe("Session Configuration", async () => {
6766

6867
const session = await client.createSession({ onPermissionRequest: approveAll });
6968

70-
await session.send({
69+
await session.sendAndWait({
7170
prompt: "Summarize the attached file",
7271
attachments: [{ type: "file", path: join(workDir, "attached.txt") }],
7372
});
7473

75-
// Just verify send doesn't throw — attachment support varies by runtime
7674
await session.disconnect();
7775
});
7876

test/snapshots/session_config/should_accept_blob_attachments.yaml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,100 @@ conversations:
55
- role: system
66
content: ${system}
77
- role: user
8-
content: Describe this image
8+
content: |-
9+
Describe this image
10+
test-pixel.png
11+
[image]
12+
- role: assistant
13+
content: I'll view the image for you.
14+
- role: assistant
15+
tool_calls:
16+
- id: toolcall_0
17+
type: function
18+
function:
19+
name: report_intent
20+
arguments: '{"intent":"Viewing image file"}'
21+
- role: assistant
22+
tool_calls:
23+
- id: toolcall_1
24+
type: function
25+
function:
26+
name: view
27+
arguments: '{"path":"${workdir}/test-pixel.png"}'
28+
- messages:
29+
- role: system
30+
content: ${system}
31+
- role: user
32+
content: |-
33+
Describe this image
34+
test-pixel.png
35+
[image]
36+
- role: assistant
37+
content: I'll view the image for you.
38+
tool_calls:
39+
- id: toolcall_0
40+
type: function
41+
function:
42+
name: report_intent
43+
arguments: '{"intent":"Viewing image file"}'
44+
- id: toolcall_1
45+
type: function
46+
function:
47+
name: view
48+
arguments: '{"path":"${workdir}/test-pixel.png"}'
49+
- role: tool
50+
tool_call_id: toolcall_0
51+
content: Intent logged
52+
- role: tool
53+
tool_call_id: toolcall_1
54+
content: Path ${workdir}/test-pixel.png does not exist. Please provide a valid path.
55+
- role: assistant
56+
content: Let me check the current directory to locate the image file.
57+
- role: assistant
58+
tool_calls:
59+
- id: toolcall_2
60+
type: function
61+
function:
62+
name: ${shell}
63+
arguments: '{"command":"Get-ChildItem -Recurse -Filter \"test-pixel.png\"","description":"Find test-pixel.png file"}'
64+
- messages:
65+
- role: system
66+
content: ${system}
67+
- role: user
68+
content: |-
69+
Describe this image
70+
test-pixel.png
71+
[image]
72+
- role: assistant
73+
content: I'll view the image for you.
74+
tool_calls:
75+
- id: toolcall_0
76+
type: function
77+
function:
78+
name: report_intent
79+
arguments: '{"intent":"Viewing image file"}'
80+
- id: toolcall_1
81+
type: function
82+
function:
83+
name: view
84+
arguments: '{"path":"${workdir}/test-pixel.png"}'
85+
- role: tool
86+
tool_call_id: toolcall_0
87+
content: Intent logged
88+
- role: tool
89+
tool_call_id: toolcall_1
90+
content: Path ${workdir}/test-pixel.png does not exist. Please provide a valid path.
91+
- role: assistant
92+
content: Let me check the current directory to locate the image file.
93+
tool_calls:
94+
- id: toolcall_2
95+
type: function
96+
function:
97+
name: ${shell}
98+
arguments: '{"command":"Get-ChildItem -Recurse -Filter \"test-pixel.png\"","description":"Find test-pixel.png file"}'
99+
- role: tool
100+
tool_call_id: toolcall_2
101+
content: <exited with exit code 0>
102+
- role: assistant
103+
content: The file doesn't appear to be in the working directory. Could you please upload or provide the image file
104+
again? I'll be happy to describe it once I can access it.

test/snapshots/session_config/should_accept_message_attachments.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,53 @@ conversations:
1313
<tagged_files>
1414
* ${workdir}/attached.txt (1 lines)
1515
</tagged_files>
16+
- role: assistant
17+
content: I'll read the attached file and summarize it for you.
18+
- role: assistant
19+
tool_calls:
20+
- id: toolcall_0
21+
type: function
22+
function:
23+
name: report_intent
24+
arguments: '{"intent":"Reading attached file"}'
25+
- role: assistant
26+
tool_calls:
27+
- id: toolcall_1
28+
type: function
29+
function:
30+
name: view
31+
arguments: '{"path":"${workdir}/attached.txt"}'
32+
- messages:
33+
- role: system
34+
content: ${system}
35+
- role: user
36+
content: |-
37+
Summarize the attached file
38+
39+
40+
41+
<tagged_files>
42+
* ${workdir}/attached.txt (1 lines)
43+
</tagged_files>
44+
- role: assistant
45+
content: I'll read the attached file and summarize it for you.
46+
tool_calls:
47+
- id: toolcall_0
48+
type: function
49+
function:
50+
name: report_intent
51+
arguments: '{"intent":"Reading attached file"}'
52+
- id: toolcall_1
53+
type: function
54+
function:
55+
name: view
56+
arguments: '{"path":"${workdir}/attached.txt"}'
57+
- role: tool
58+
tool_call_id: toolcall_0
59+
content: Intent logged
60+
- role: tool
61+
tool_call_id: toolcall_1
62+
content: 1. This file is attached
63+
- role: assistant
64+
content: The attached file contains a single line of text that simply states "This file is attached" - it's a minimal
65+
test file confirming its attachment status.

0 commit comments

Comments
 (0)