Skip to content

Commit b743231

Browse files
committed
Merge tests
1 parent 968bb3a commit b743231

File tree

2 files changed

+31
-38
lines changed

2 files changed

+31
-38
lines changed

src/core/assistant-message/__tests__/parseAssistantMessage-inline-tool.test.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/core/assistant-message/__tests__/parseAssistantMessage.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,37 @@ const isEmptyTextContent = (block: AssistantMessageContent) =>
335335
expect(result[5].type).toBe("tool_use")
336336
expect((result[5] as ToolUse).name).toBe("execute_command")
337337
})
338+
339+
it("treats inline <read_file> mention as plain text", () => {
340+
const message = "Use the `<read_file>` tool when you need to read a file."
341+
const result = parser(message)
342+
expect(result).toHaveLength(1)
343+
expect(result[0].type).toBe("text")
344+
})
345+
346+
it("treats fenced code block mention as plain text", () => {
347+
const message = [
348+
"Here is an example:",
349+
"```",
350+
"<read_file>",
351+
"<path>demo.txt</path>",
352+
"</read_file>",
353+
"```",
354+
].join("\n")
355+
const result = parser(message)
356+
expect(result).toHaveLength(1)
357+
expect(result[0].type).toBe("text")
358+
})
359+
360+
it("parses real tool invocation with newline correctly", () => {
361+
const invocation = ["<read_file>", "<path>demo.txt</path>", "</read_file>"].join("\n")
362+
const result = parser(invocation)
363+
expect(result).toHaveLength(1)
364+
const tool = result[0]
365+
if (tool.type !== "tool_use") throw new Error("Expected tool_use block")
366+
expect(tool.name).toBe("read_file")
367+
expect(tool.params.path).toBe("demo.txt")
368+
})
338369
})
339370
})
340371
})

0 commit comments

Comments
 (0)