@@ -17,7 +17,6 @@ T = new_set({
1717 post_case = function ()
1818 child .lua ([[
1919 _G.chat = nil
20- _G.codecompanion_current_tool = nil
2120 ]] )
2221 end ,
2322 post_once = child .stop ,
@@ -66,8 +65,8 @@ T["Workflows"]["prompts are sequentially added to the chat buffer"] = function()
6665 name = "Repeat On Failure",
6766 role = "user",
6867 opts = { auto_submit = false },
69- condition = function()
70- return _G.codecompanion_current_tool == "cmd_runner"
68+ condition = function(chat )
69+ return chat.tools.tool and chat.tools.tool.name == "cmd_runner"
7170 end,
7271 repeat_until = function(chat)
7372 return chat.tool_registry.flags.testing == true
@@ -80,8 +79,8 @@ T["Workflows"]["prompts are sequentially added to the chat buffer"] = function()
8079 name = "Success",
8180 role = "user",
8281 opts = { auto_submit = false },
83- condition = function()
84- return not _G.codecompanion_current_tool
82+ condition = function(chat )
83+ return not chat.tools.tool
8584 end,
8685 content = "Tests passed!",
8786 },
@@ -100,15 +99,15 @@ T["Workflows"]["prompts are sequentially added to the chat buffer"] = function()
10099 h .eq (" First prompt" , last_line )
101100
102101 -- Mock failing tool, twice
103- child .lua ([[ _G.codecompanion_current_tool = "cmd_runner"]] )
102+ child .lua ([[ _G.chat.tools.tool = { name = "cmd_runner" } ]] )
104103 child .lua ([[ h.send_to_llm(_G.chat, "Calling a tool...")]] )
105104 last_line = child .lua ([[
106105 local lines = h.get_buf_lines(_G.chat.bufnr)
107106 return lines[#lines]
108107 ]] )
109108 h .eq (" The tests have failed" , last_line )
110109
111- child .lua ([[ _G.codecompanion_current_tool = "cmd_runner"]] )
110+ child .lua ([[ _G.chat.tools.tool = { name = "cmd_runner" } ]] )
112111 child .lua ([[ h.send_to_llm(_G.chat, "Calling a tool...")]] )
113112 last_line = child .lua ([[
114113 local lines = h.get_buf_lines(_G.chat.bufnr)
@@ -119,7 +118,7 @@ T["Workflows"]["prompts are sequentially added to the chat buffer"] = function()
119118 -- Now pass tests; unset tool after this turn
120119 child .lua ([[
121120 _G.chat.tool_registry.flags.testing = true
122- h.send_to_llm(_G.chat, "Calling a tool...", function() _G.codecompanion_current_tool = nil end)
121+ h.send_to_llm(_G.chat, "Calling a tool...", function() _G.chat.tools.tool = nil end)
123122 ]] )
124123 last_line = child .lua ([[
125124 local lines = h.get_buf_lines(_G.chat.bufnr)
0 commit comments