File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ return {
11
11
},
12
12
opts = {
13
13
vision = true ,
14
+ -- Claude Code has an annoying habit of outputting the entire contents of a
15
+ -- file in a tool call. This messes up the chat buffer formatting.
16
+ trim_tool_output = true ,
14
17
},
15
18
commands = {
16
19
default = {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ local shared = require("codecompanion.adapters.shared")
9
9
--- @field roles table The mapping of roles in the config to the LLM ' s defined roles
10
10
--- @field command table The command to execute
11
11
--- @field commands { default : table , [string] : table } The list of possible commands for the adapter. Must include a ' default' key
12
+ --- @field opts ? table Additional options for the adapter
12
13
--- @field defaults ? table Additional options for the adapter
13
14
--- @field env ? table Environment variables which can be referenced in the parameters
14
15
--- @field env_replaced ? table Replacement of environment variables with their actual values
Original file line number Diff line number Diff line change 127
127
function M .tool_message (tool_call , adapter )
128
128
local status = tool_call .status or " pending"
129
129
local title = M .short_title (tool_call )
130
+ local trim_tool_output = adapter .opts and adapter .opts .trim_tool_output
131
+
130
132
if status == " completed" then
131
133
local summary
132
- if adapter . name == " claude_code " then
134
+ if trim_tool_output then
133
135
summary = title
134
136
else
135
137
summary = M .summarize_tool_content (tool_call )
@@ -138,8 +140,13 @@ function M.tool_message(tool_call, adapter)
138
140
elseif status == " in_progress" then
139
141
return title .. " — running"
140
142
elseif status == " failed" then
141
- local summary = M .summarize_tool_content (tool_call )
142
- return summary and (title .. " — failed: " .. summary ) or (title .. " — failed" )
143
+ local summary
144
+ if trim_tool_output then
145
+ summary = title
146
+ else
147
+ summary = M .summarize_tool_content (tool_call )
148
+ end
149
+ return summary or (title .. " — failed" )
143
150
else
144
151
return title
145
152
end
You can’t perform that action at this time.
0 commit comments