Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('createFormattedToolInvocation', () => {
expect(result).toBeDefined();
expect(result!.toolName).toBe(ClaudeToolNames.Bash);
expect(result!.toolCallId).toBe('test-tool-id-123');
expect(result!.isConfirmed).toBe(true);
expect(result!.isConfirmed).toBeUndefined();
expect(result!.invocationMessage).toBe('');
expect(result!.toolSpecificData).toEqual({
commandLine: { original: 'npm install' },
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('createFormattedToolInvocation', () => {

expect(result).toBeDefined();
expect(result!.toolName).toBe(ClaudeToolNames.Read);
expect(result!.isConfirmed).toBe(true);
expect(result!.isConfirmed).toBeUndefined();
expect(result!.invocationMessage).toBeDefined();
const message = result!.invocationMessage as { value: string };
expect(message.value).toContain(URI.file('/path/to/file.ts').toString());
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('createFormattedToolInvocation', () => {
});

describe('common properties', () => {
it('sets isConfirmed to true for all non-suppressed tools', () => {
it('sets isConfirmed to true when complete=true is passed', () => {
const tools = [
ClaudeToolNames.Bash,
ClaudeToolNames.Read,
Expand All @@ -250,11 +250,29 @@ describe('createFormattedToolInvocation', () => {

for (const tool of tools) {
const toolUse = createToolUseBlock(tool, {});
const result = createFormattedToolInvocation(toolUse);
const result = createFormattedToolInvocation(toolUse, true);
expect(result?.isConfirmed).toBe(true);
}
});

it('leaves isConfirmed undefined when complete is not passed', () => {
const tools = [
ClaudeToolNames.Bash,
ClaudeToolNames.Read,
ClaudeToolNames.Glob,
ClaudeToolNames.Grep,
ClaudeToolNames.LS,
ClaudeToolNames.ExitPlanMode,
ClaudeToolNames.Task
];

for (const tool of tools) {
const toolUse = createToolUseBlock(tool, {});
const result = createFormattedToolInvocation(toolUse);
expect(result?.isConfirmed).toBeUndefined();
}
});

it('uses tool call id from tool use block', () => {
const toolUse: Anthropic.ToolUseBlock = {
type: 'tool_use',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ import { ClaudeToolNames, ExitPlanModeInput, LSInput } from './claudeTools';
*/
export function createFormattedToolInvocation(
toolUse: Anthropic.ToolUseBlock,
complete?: boolean
): ChatToolInvocationPart | undefined {
const invocation = new ChatToolInvocationPart(toolUse.name, toolUse.id, false);
invocation.isConfirmed = true;
if (complete !== undefined) {
invocation.isConfirmed = complete;
invocation.isComplete = complete;
}

switch (toolUse.name as ClaudeToolNames) {
case ClaudeToolNames.Bash:
Expand Down
8 changes: 7 additions & 1 deletion src/extension/agents/claude/node/claudeCodeAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ export class ClaudeCodeSession extends Disposable {
stream.push(new ChatResponseThinkingProgressPart(item.thinking));
} else if (item.type === 'tool_use') {
unprocessedToolCalls.set(item.id, item);
const invocation = createFormattedToolInvocation(item, false);
if (invocation) {
invocation.enablePartialUpdate = true;
stream.push(invocation);
}
}
}
}
Expand Down Expand Up @@ -632,8 +637,9 @@ export class ClaudeCodeSession extends Disposable {
}

unprocessedToolCalls.delete(toolResult.tool_use_id!);
const invocation = createFormattedToolInvocation(toolUse);
const invocation = createFormattedToolInvocation(toolUse, true);
if (invocation) {
invocation.enablePartialUpdate = true;
invocation.isError = toolResult.is_error;
if (toolResult.content === ClaudeCodeSession.DenyToolMessage) {
invocation.isConfirmed = false;
Expand Down
6 changes: 6 additions & 0 deletions src/extension/vscode.proposed.chatParticipantAdditions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ declare module 'vscode' {
subAgentInvocationId?: string;
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;

/**
* If this flag is set, this will be treated as an update to any previous tool call with the same id.
* TODO@roblourens remove this and make it the default
*/
enablePartialUpdate?: boolean;

constructor(toolName: string, toolCallId: string, isError?: boolean);
}

Expand Down