Skip to content

Commit b8e20ad

Browse files
voidstackloopclaude
andcommitted
e2e: fix real intermittent IPC drop in agent-tool-approval tests
The diagnostics added last time confirmed the chat request always reaches the fake Ollama server (request count incremented correctly on every failure) — the response chunk carrying the tool call was the thing going missing, not the request. This is the same class of bug already documented in fake-ollama.ts (Electron can silently coalesce/drop a webContents.send() that lands in the same event-loop tick as another IPC send), just triggered by a different neighbor: enabling agent mode kicks off its own background IPC (sessions:update, agentTools.detectProjectScripts()), and the tool-call turn is a single chunk carrying the *entire* response, so losing it leaves nothing behind to recover — unlike token streaming, where losing one chunk mid-stream still leaves partial text. Fix: let agent-mode side effects settle (300ms) before sending, and widen the tool-call turn's own response delay (250ms, up from the fixture's 15ms default) for more headroom. Passed 3x repeated locally plus the full suite; previously flaked deterministically on CI even at a 30s wait. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 9865f82 commit b8e20ad

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

e2e/tests/agent-tool-approval.spec.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,25 @@ async function enableAgentModeAndSendToolCallingMessage(instance_: LaunchedApp):
5555
await window.getByRole("button", { name: "Agent", exact: true }).click();
5656
await expect(window.getByRole("button", { name: /Agent/ })).toHaveAttribute("aria-pressed", "true");
5757

58-
fakeOllama.setNextChatTurn({ toolCall: { name: "run_command", arguments: { command: "echo hello-from-agent" } } });
58+
// Enabling agent mode kicks off its own IPC round trips in the
59+
// background (sessions:update, agentTools.detectProjectScripts() via the
60+
// agentWorkspace effect) — sending the chat message immediately risks
61+
// its single-chunk tool-call response's webContents.send() landing in
62+
// the same event-loop tick as one of those, which Electron can coalesce
63+
// away silently (this is the same class of bug worked around in
64+
// fake-ollama.ts's DEFAULT_DELAY_MS, just triggered by a different
65+
// neighbor now that agent mode is in play). Letting things settle first
66+
// is cheaper and more direct than only padding the response delay.
67+
await window.waitForTimeout(300);
68+
69+
fakeOllama.setNextChatTurn({
70+
toolCall: { name: "run_command", arguments: { command: "echo hello-from-agent" } },
71+
// Wider than the fixture's own default — this response is a single
72+
// chunk carrying the *entire* tool call, so if Electron drops it,
73+
// there's no partial content left behind to recover; CI has shown
74+
// this needs more headroom than plain streaming does.
75+
delayMs: 250,
76+
});
5977

6078
const input = window.getByPlaceholder("Send a message...");
6179
await input.fill("run a command for me");

0 commit comments

Comments
 (0)