File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
tests/interactions/chat/tools/builtin Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff 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 ]] )
4753end
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!" )
109116end
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\n Again!" )
129137end
130138
You can’t perform that action at this time.
0 commit comments