test(voice): pin the deadline each chat map action gets

Three 40 ms actions in one round outlast a 50 ms deadline unless each
action re-arms it, so removing that re-arm now fails the test for both
providers.
This commit is contained in:
Sameh Khamis committed 2026-11-03 15:54:59 -08:00
1 parent eed6162753
commit 66fb4b6aca
1 file changed
+25
+25
View File
@@ -403,6 +403,31 @@ for (const provider of ['openai', 'gemini']) {
assert.equal(h.completions().length, 1);
h.chat.stop();
});
test(`${provider}: each map action in a round gets its own deadline`, async (context) => {
context.mock.timers.enable({ apis: ['setTimeout'] });
let pending = 0;
const h = harness(provider, (n) => (n < 2 ? w.calls(3) : w.final('Done')), {
chat: { timeoutMs: 50 },
runAction: () =>
new Promise((resolve) => {
pending++;
setTimeout(() => resolve({ ok: true }), 40);
}),
});
h.chat.start();
h.chat.sendText('Three slow steps');
// One request, then three 40 ms actions: 120 ms against a 50 ms deadline.
for (const expected of [1, 2, 3]) {
await settle();
assert.equal(pending, expected);
context.mock.timers.tick(40);
}
await settle();
assert.equal(h.errors().length, 0);
assert.equal(h.completions().length, 1);
h.chat.stop();
});
}
test('long history shortens old tool results and keeps every call paired', async () => {