Skip to content

Commit 32dd2da

Browse files
authored
fix(acp): show urls in tool output (#2403)
Co-authored-by: Oli Morris <[email protected]>
1 parent 68fcda0 commit 32dd2da

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

.codecompanion/acp/claude_code_acp.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ When doing a web search:
6767
Fetching a specific web page:
6868

6969
```json
70-
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019a5121-cbef-746c-aece-adc08cef75cd","update":{"toolCallId":"toolu_01V4sSXxJ5CQALc3sKQR5mCu","sessionUpdate":"tool_call","rawInput":{},"status":"pending","title":"Fetch","kind":"fetch","content":[]}}}
71-
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019a5121-cbef-746c-aece-adc08cef75cd","update":{"toolCallId":"toolu_01V4sSXxJ5CQALc3sKQR5mCu","sessionUpdate":"tool_call","rawInput":{"url":"https://example.com","prompt":"Summarize the content of this webpage"},"status":"pending","title":"Fetch https://example.com","kind":"fetch","content":[{"type":"content","content":{"type":"text","text":"Summarize the content of this webpage"}}]}}}
72-
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019a5121-cbef-746c-aece-adc08cef75cd","update":{"toolCallId":"toolu_01V4sSXxJ5CQALc3sKQR5mCu","sessionUpdate":"tool_call_update","status":"completed","content":[{"type":"content","content":{"type":"text","text":"# Webpage Summary\n\nThis is the \"Example Domain\" page, a resource provided by IANA (Internet Assigned Numbers Authority). The page states that \"This domain is for use in documentation examples without needing permission.\" The site advises users to avoid utilizing it for operational purposes. \n\nThe page includes minimal styling and a link directing visitors to learn more information on IANA's website about example domains. It serves as a placeholder or reference point for developers and documentarians who need to demonstrate concepts in their work."}}]}}}
70+
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019a9608-3313-73bd-9f76-292536a97ff6","update":{"_meta":{"claudeCode":{"toolName":"WebFetch"}},"toolCallId":"toolu_01J8pCXnGC3oSe8uZ8GVguiL","sessionUpdate":"tool_call","rawInput":{"url":"https://agentclientprotocol.com/protocol/terminals","prompt":"Extract and summarize the complete terminal protocol specification including all methods, request/response formats, and key features."},"status":"pending","title":"Fetch https://agentclientprotocol.com/protocol/terminals","kind":"fetch","content":[{"type":"content","content":{"type":"text","text":"Extract and summarize the complete terminal protocol specification including all methods, request/response formats, and key features."}}]}}}
71+
72+
{"jsonrpc":"2.0","id":0,"method":"session/request_permission","params":{"options":[{"kind":"allow_always","name":"Always Allow","optionId":"allow_always"},{"kind":"allow_once","name":"Allow","optionId":"allow"},{"kind":"reject_once","name":"Reject","optionId":"reject"}],"sessionId":"019a9608-3313-73bd-9f76-292536a97ff6","toolCall":{"toolCallId":"toolu_01J8pCXnGC3oSe8uZ8GVguiL","rawInput":{"url":"https://agentclientprotocol.com/protocol/terminals","prompt":"Extract and summarize the complete terminal protocol specification including all methods, request/response formats, and key features."},"title":"Fetch https://agentclientprotocol.com/protocol/terminals"}}}
73+
74+
{"jsonrpc":"2.0","result":{"outcome":{"optionId":"allow","outcome":"selected"}},"id":0}
75+
76+
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019a9608-3313-73bd-9f76-292536a97ff6","update":{"_meta":{"claudeCode":{"toolResponse":{"bytes":7001,"code":200,"codeText":"OK","result":"# Terminal Protocol Specification Summary\n\n## Overview\nThe terminal protocol enables Claude agents to execute shell commands within a client's environment, with real-time output streaming and process management capabilities.\n\n## Capability Checking\nAgents must verify terminal support via the `initialize` response, checking that `clientCapabilities.terminal` is `true` before attempting any terminal operations.\n\n## Core Methods\n\n**terminal/create**\nInitiates a command in a new terminal. Parameters include command, arguments, environment variables, working directory, and output byte limits. Returns a terminal ID immediately for background execution.\n\n**terminal/output**\nRetrieves current command output without waiting for completion. Response includes output text, truncation status, and exit information if the process has finished.\n\n**terminal/wait_for_exit**\nBlocks until the command completes, returning the exit code and termination signal.\n\n**terminal/kill**\nTerminates a running command while preserving the terminal for further operations like output retrieval.\n\n**terminal/release**\nKills any running command and deallocates terminal resources. The terminal ID becomes invalid afterward.\n\n## Key Features\n\n- **Background Execution**: Commands run asynchronously, allowing agents to perform other operations\n- **Output Management**: \"Maximum number of output bytes to retain. Once exceeded, earlier output is truncated\" while maintaining character boundaries\n- **Tool Integration**: Terminals embed directly in tool calls for live user-facing output\n- **Timeout Implementation**: Agents can implement timeouts by racing `wait_for_exit` against a timer, then calling kill if needed\n- **Resource Management**: Agents must explicitly release terminals to prevent resource leaks","durationMs":5317,"url":"https://agentclientprotocol.com/protocol/terminals"},"toolName":"WebFetch"}},"toolCallId":"toolu_01J8pCXnGC3oSe8uZ8GVguiL","sessionUpdate":"tool_call_update"}}}
7377
```

lua/codecompanion/config.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,9 +1312,9 @@ You must create or modify a workspace file through a series of prompts over mult
13121312
buffer_watch = "󰂥 ",
13131313
--chat_context = " ",
13141314
chat_fold = "",
1315-
tool_pending = "",
1316-
tool_in_progress = "",
1317-
tool_failure = "",
1315+
tool_pending = " ",
1316+
tool_in_progress = " ",
1317+
tool_failure = " ",
13181318
tool_success = "",
13191319
},
13201320
-- Window options for the chat buffer

lua/codecompanion/strategies/chat/acp/formatters.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,15 @@ local function extract_operation(title)
140140
title = title:gsub("%s*=>.*$", "")
141141
title = title:gsub("%s*—.*$", "")
142142

143-
-- If "name: something", keep the name only for some cases
143+
-- If "name: something", keep the full thing if it looks like a URL
144+
-- Otherwise, for short prefixes, keep just the prefix
144145
local before_colon = title:match("^%s*([^:]+)%s*:")
145146
if before_colon and #before_colon < 40 then
146-
title = before_colon
147+
-- Don't strip if the part after colon looks like a URL
148+
local after_colon = title:match("^%s*[^:]+%s*:%s*(.+)")
149+
if not (after_colon and (after_colon:match("^//") or after_colon:match("^https?://"))) then
150+
title = before_colon
151+
end
147152
end
148153

149154
-- Clean up trailing whitespace

0 commit comments

Comments
 (0)