Skip to content

Commit 825f5ea

Browse files
authored
feat(tools): system_prompt in tool groups can be a function (#1210)
1 parent db2d120 commit 825f5ea

File tree

1 file changed

+7
-2
lines changed
  • lua/codecompanion/strategies/chat/agents

1 file changed

+7
-2
lines changed

lua/codecompanion/strategies/chat/agents/init.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,15 @@ function Agent:parse(chat, message)
283283

284284
if groups and not vim.tbl_isempty(groups) then
285285
for _, group in ipairs(groups) do
286-
if self.tools_config.groups[group].system_prompt then
286+
local schema = self.tools_config.groups[group]
287+
local system_prompt = schema.system_prompt
288+
if type(system_prompt) == "function" then
289+
system_prompt = system_prompt(schema)
290+
end
291+
if system_prompt then
287292
chat:add_message({
288293
role = config.constants.SYSTEM_ROLE,
289-
content = self.tools_config.groups[group].system_prompt,
294+
content = system_prompt,
290295
}, { tag = "tool", visible = false })
291296
end
292297
end

0 commit comments

Comments
 (0)