Skip to content

Commit ff5b5a4

Browse files
Fix web_fetch tool showing empty content when expanded
- Add formatWebFetchInvocation() in copilotCLITools.ts to show URL in invocationMessage/pastTenseMessage - Add web_fetch handling in copilotToolDisplay.ts getInvocationMessage/getPastTenseMessage - Add test for web_fetch invocation formatting Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/26446ad4-2529-41d2-b8c5-a3b073ef2a4b Co-authored-by: DonJayamanne <1948812+DonJayamanne@users.noreply.github.com>
1 parent 0c94333 commit ff5b5a4

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

extensions/copilot/src/extension/chatSessions/copilotcli/common/copilotCLITools.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ const ToolFriendlyNameAndHandlers: { [K in ToolCall['toolName']]: [title: string
10611061
'report_intent': [l10n.t('Report Intent'), emptyInvocation, genericToolInvocationCompleted],
10621062
'think': [l10n.t('Thinking'), emptyInvocation, genericToolInvocationCompleted],
10631063
'report_progress': [l10n.t('Progress update'), formatProgressToolInvocation, genericToolInvocationCompleted],
1064-
'web_fetch': [l10n.t('Fetch Web Content'), emptyInvocation, genericToolInvocationCompleted],
1064+
'web_fetch': [l10n.t('Fetch Web Content'), formatWebFetchInvocation, genericToolInvocationCompleted],
10651065
'web_search': [l10n.t('Web Search'), emptyInvocation, genericToolInvocationCompleted],
10661066
'update_todo': [l10n.t('Update Todo'), formatUpdateTodoInvocation, formatUpdateTodoInvocationCompleted],
10671067
'show_file': [l10n.t('Show File'), formatShowFileInvocation, genericToolInvocationCompleted],
@@ -1101,6 +1101,15 @@ function formatProgressToolInvocation(invocation: ChatToolInvocationPart, toolCa
11011101

11021102

11031103

1104+
function formatWebFetchInvocation(invocation: ChatToolInvocationPart, toolCall: WebFetchTool): void {
1105+
const url = toolCall.arguments.url;
1106+
if (url) {
1107+
const displayUrl = url.length > 80 ? url.substring(0, 77) + '...' : url;
1108+
invocation.invocationMessage = l10n.t("Fetching {0}", displayUrl);
1109+
invocation.pastTenseMessage = l10n.t("Fetched {0}", displayUrl);
1110+
}
1111+
}
1112+
11041113
function formatViewToolInvocation(invocation: ChatToolInvocationPart, toolCall: ViewTool): void {
11051114
const args = toolCall.arguments;
11061115

extensions/copilot/src/extension/chatSessions/copilotcli/common/test/copilotCLITools.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,11 @@ describe('CopilotCLITools', () => {
563563
const part = createCopilotCLIToolInvocation({ toolName: 'codeql_checker', toolCallId: 'cq1', arguments: {} });
564564
expect(part).toBeInstanceOf(ChatToolInvocationPart);
565565
});
566+
it('formats web_fetch invocation with url', () => {
567+
const part = createCopilotCLIToolInvocation({ toolName: 'web_fetch', toolCallId: 'wf1', arguments: { url: 'https://example.com/page' } });
568+
expect(part).toBeInstanceOf(ChatToolInvocationPart);
569+
expect(getInvocationMessageText(part as ChatToolInvocationPart)).toContain('https://example.com/page');
570+
});
566571
});
567572

568573
describe('process tool execution lifecycle', () => {

src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ interface ICopilotGlobToolArgs {
8080
path?: string;
8181
}
8282

83+
/** Parameters for the `web_fetch` tool. */
84+
interface ICopilotWebFetchToolArgs {
85+
url: string;
86+
}
87+
8388
/** Set of tool names that perform file edits. */
8489
const EDIT_TOOL_NAMES: ReadonlySet<string> = new Set([
8590
CopilotToolName.Edit,
@@ -245,6 +250,13 @@ export function getInvocationMessage(toolName: string, displayName: string, para
245250
}
246251
return localize('toolInvoke.glob', "Finding files");
247252
}
253+
case CopilotToolName.WebFetch: {
254+
const args = parameters as ICopilotWebFetchToolArgs | undefined;
255+
if (args?.url) {
256+
return md(localize('toolInvoke.webFetch', "Fetching {0}", appendEscapedMarkdownInlineCode(truncate(args.url, 80))));
257+
}
258+
return localize('toolInvoke.webFetchGeneric', "Fetching web content");
259+
}
248260
default:
249261
return localize('toolInvoke.generic', "Using \"{0}\"", displayName);
250262
}
@@ -300,6 +312,13 @@ export function getPastTenseMessage(toolName: string, displayName: string, param
300312
}
301313
return localize('toolComplete.glob', "Found files");
302314
}
315+
case CopilotToolName.WebFetch: {
316+
const args = parameters as ICopilotWebFetchToolArgs | undefined;
317+
if (args?.url) {
318+
return md(localize('toolComplete.webFetch', "Fetched {0}", appendEscapedMarkdownInlineCode(truncate(args.url, 80))));
319+
}
320+
return localize('toolComplete.webFetchGeneric', "Fetched web content");
321+
}
303322
default:
304323
return localize('toolComplete.generic', "Used \"{0}\"", displayName);
305324
}

0 commit comments

Comments
 (0)