Skip to content

Commit 9c7db8b

Browse files
slg95Spencer Gray
authored andcommitted
tests: Add LLM tool call message to test_tool_output.
1 parent 408fe2c commit 9c7db8b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/interactions/chat/tools/builtin/test_tool_output.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ function tool_call(c)
4343
type = "function",
4444
},
4545
}
46+
47+
-- Add the tool call message to chat.messages (as done() would do)
48+
_G.chat:add_message({
49+
role = "assistant",
50+
tool_calls = { _G.tool.function_call },
51+
}, { visible = false })
4652
]])
4753
end
4854

@@ -98,13 +104,14 @@ T["Tool output"]["first call creates one message"] = function()
98104
chat:add_tool_output(_G.tool, "Hello!")
99105
100106
-- return how many chat.messages and that message's content
107+
-- Expected: system message + tool call message + tool result message = 3
101108
return {
102109
count = #chat.messages,
103110
content = chat.messages[#chat.messages].content,
104111
}
105112
]])
106113

107-
h.eq(output.count, 2)
114+
h.eq(output.count, 3)
108115
h.eq(output.content, "Hello!")
109116
end
110117

@@ -124,7 +131,8 @@ T["Tool output"]["second call appends to same message"] = function()
124131
}
125132
]])
126133

127-
h.eq(output.count, 2)
134+
-- Still 3 messages because second call merges with first tool result
135+
h.eq(output.count, 3)
128136
h.eq(output.content, "Hello!\n\nAgain!")
129137
end
130138

0 commit comments

Comments
 (0)