Skip to content

Commit 175770f

Browse files
committed
test(task): cover noButtonClicked on tool repetition hard block
1 parent fbe35c0 commit 175770f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/core/assistant-message/__tests__/presentAssistantMessage-tool-repetition.spec.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,29 @@ describe("presentAssistantMessage - Tool Repetition Detection", () => {
370370
expect(toolResult?.content).toContain("read_file")
371371
})
372372

373+
it("should not run the tool when the user answers no to a hard block, and should reset the streak", async () => {
374+
const toolCallId = "tool_call_hard_block_no"
375+
const block = makeReadFileBlock(toolCallId)
376+
primeDetector(detector, block, HARD_LIMIT)
377+
mockTask.assistantMessageContent = [block]
378+
379+
mockTask.ask = vi.fn().mockResolvedValue({ response: "noButtonClicked" })
380+
381+
await present()
382+
383+
expect(mockTask.ask).toHaveBeenCalledTimes(1)
384+
expect(readFileHandle).not.toHaveBeenCalled()
385+
expect(findToolResult(toolCallId)?.content).toContain("read_file")
386+
387+
// The hard block resets the streak, so the same call runs on the next turn.
388+
const nextBlock = makeReadFileBlock("tool_call_after_hard_block_no")
389+
startNextTurn([nextBlock])
390+
391+
await present()
392+
393+
expect(readFileHandle).toHaveBeenCalledTimes(1)
394+
})
395+
373396
it("should incorporate user feedback when the user responds to a hard block", async () => {
374397
const toolCallId = "tool_call_hard_block_feedback"
375398
const block = makeReadFileBlock(toolCallId)

0 commit comments

Comments
 (0)