Skip to content

Commit a3361d8

Browse files
committed
test(assistant-message): cover alias-normalized disabledTools validation
1 parent 5fba8c6 commit a3361d8

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { describe, it, expect, beforeEach, vi } from "vitest"
44
import { presentAssistantMessage } from "../presentAssistantMessage"
5+
import { validateToolUse } from "../../tools/validateToolUse"
56

67
// Mock dependencies
78
vi.mock("../../task/Task")
@@ -301,6 +302,44 @@ describe("presentAssistantMessage - Custom Tool Recording", () => {
301302
})
302303
})
303304

305+
describe("Validation requirements", () => {
306+
it("normalizes disabledTools aliases before validateToolUse", async () => {
307+
const toolCallId = "tool_call_validation_alias_123"
308+
mockTask.assistantMessageContent = [
309+
{
310+
type: "tool_use",
311+
id: toolCallId,
312+
name: "some_unknown_tool",
313+
params: {},
314+
partial: false,
315+
},
316+
]
317+
318+
mockTask.providerRef = {
319+
deref: () => ({
320+
getState: vi.fn().mockResolvedValue({
321+
mode: "code",
322+
customModes: [],
323+
experiments: {
324+
customTools: false,
325+
},
326+
disabledTools: ["search_and_replace"],
327+
}),
328+
}),
329+
}
330+
331+
await presentAssistantMessage(mockTask)
332+
333+
const validateToolUseMock = vi.mocked(validateToolUse)
334+
expect(validateToolUseMock).toHaveBeenCalled()
335+
const toolRequirements = validateToolUseMock.mock.calls[0][3]
336+
expect(toolRequirements).toMatchObject({
337+
search_and_replace: false,
338+
edit: false,
339+
})
340+
})
341+
})
342+
304343
describe("Partial blocks", () => {
305344
it("should not record usage for partial custom tool blocks", async () => {
306345
mockTask.assistantMessageContent = [

0 commit comments

Comments
 (0)