Skip to content

Commit 557a29f

Browse files
committed
Reset harness queue snapshot on run start
1 parent 08fdeff commit 557a29f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

packages/agent/src/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ export class CuaAgentHarness<
533533
if (recovery && recovery.maxAttempts > 0) {
534534
this.on("before_agent_start", () => {
535535
this.emptyResponseRecoveryAttempts = 0;
536+
this.hasPendingActiveQueue = false;
536537
return undefined;
537538
});
538539
this.subscribe(async (event, signal) => {

packages/agent/test/agent.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,24 @@ describe("CuaAgentHarness", () => {
767767
expect(scripted.calls()).toBe(4);
768768
});
769769

770+
it("clears stale queue snapshots before a new prompt starts", async () => {
771+
const scripted = createScriptedModels([undefined, "finished"]);
772+
const harness = new CuaAgentHarness({
773+
...(await createHarnessServices()),
774+
browser,
775+
client,
776+
model: "openai:gpt-5.5",
777+
models: scripted.models,
778+
emptyResponseRecovery: recovery,
779+
});
780+
781+
(harness as unknown as { hasPendingActiveQueue: boolean }).hasPendingActiveQueue = true;
782+
const response = await harness.prompt("finish the task");
783+
784+
expect(scripted.calls()).toBe(2);
785+
expect(response.content).toEqual([{ type: "text", text: "finished" }]);
786+
});
787+
770788
it("makes exactly one additional call per configured attempt", async () => {
771789
const scripted = createScriptedModels([undefined, undefined, undefined]);
772790
const harness = new CuaAgentHarness({

0 commit comments

Comments
 (0)