Skip to content
Merged
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
16 changes: 12 additions & 4 deletions integration-tests/ripgrep-real.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ describe('ripgrep-real-direct', () => {

it('should find matches using the real ripgrep binary', async () => {
const invocation = tool.build({ pattern: 'hello' });
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.llmContent).toContain('Found 2 matches');
expect(result.llmContent).toContain('file1.txt');
Expand All @@ -90,7 +92,9 @@ describe('ripgrep-real-direct', () => {

it('should handle no matches correctly', async () => {
const invocation = tool.build({ pattern: 'nonexistent_pattern_123' });
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.llmContent).toContain('No matches found');
});
Expand All @@ -106,7 +110,9 @@ describe('ripgrep-real-direct', () => {
pattern: 'hello',
include_pattern: '*.js',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.llmContent).toContain('Found 1 match');
expect(result.llmContent).toContain('script.js');
Expand All @@ -124,7 +130,9 @@ describe('ripgrep-real-direct', () => {
pattern: 'match',
context: 1,
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.llmContent).toContain('Found 1 match');
expect(result.llmContent).toContain('context.txt');
Expand Down
4 changes: 2 additions & 2 deletions packages/a2a-server/src/commands/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export class AddMemoryCommand implements Command {
const tool = toolRegistry.getTool(result.toolName);
if (tool) {
const abortController = new AbortController();
const signal = abortController.signal;
await tool.buildAndExecute(result.toolArgs, signal, undefined, {
const abortSignal = abortController.signal;
await tool.buildAndExecute(result.toolArgs, abortSignal, undefined, {
shellExecutionConfig: {
sanitizationConfig: DEFAULT_SANITIZATION_CONFIG,
sandboxManager: loopContext.sandboxManager,
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/acp/acpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,9 @@ export class Session {
});
}

const toolResult: ToolResult = await invocation.execute(abortSignal);
const toolResult: ToolResult = await invocation.execute({
abortSignal,
});
const content = toToolCallContent(toolResult);

const updateContent: acp.ToolCallContent[] = content ? [content] : [];
Expand Down Expand Up @@ -1671,7 +1673,7 @@ export class Session {
kind: toAcpToolKind(readManyFilesTool.kind),
});

const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
const content = toToolCallContent(result) || {
type: 'content',
content: {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/ui/hooks/atCommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ async function readLocalFiles(
let invocation: AnyToolInvocation | undefined = undefined;
try {
invocation = readManyFilesTool.build(toolArgs);
const result = await invocation.execute(signal);
const result = await invocation.execute({ abortSignal: signal });
const display: IndividualToolCallDisplay = {
callId: `client-read-${userMessageTimestamp}`,
name: readManyFilesTool.displayName,
Expand Down
13 changes: 7 additions & 6 deletions packages/core/src/agents/agent-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
type ToolResult,
BaseToolInvocation,
type ToolCallConfirmationDetails,
type ToolLiveOutput,
type ExecuteOptions,
} from '../tools/tools.js';
import { type AgentLoopContext } from '../config/agent-loop-context.js';
import type { MessageBus } from '../confirmation-bus/message-bus.js';
Expand Down Expand Up @@ -185,10 +185,8 @@ class DelegateInvocation extends BaseToolInvocation<
return invocation.shouldConfirmExecute(abortSignal);
}

async execute(
signal: AbortSignal,
updateOutput?: (output: ToolLiveOutput) => void,
): Promise<ToolResult> {
async execute(options: ExecuteOptions): Promise<ToolResult> {
const { abortSignal: signal, updateOutput } = options;
const hintedParams = this.withUserHints(this.mappedInputs);
const invocation = this.buildChildInvocation(hintedParams);

Expand All @@ -204,7 +202,10 @@ class DelegateInvocation extends BaseToolInvocation<
},
async ({ metadata }) => {
metadata.input = this.params;
const result = await invocation.execute(signal, updateOutput);
const result = await invocation.execute({
abortSignal: signal,
updateOutput,
});
metadata.output = result;
return result;
},
Expand Down
26 changes: 19 additions & 7 deletions packages/core/src/agents/browser/analyzeScreenshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Find the blue submit button',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

// Verify screenshot was captured
expect(browserManager.callTool).toHaveBeenCalledWith(
Expand Down Expand Up @@ -165,7 +167,7 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Find the search bar',
});
await invocation.execute(new AbortController().signal);
await invocation.execute({ abortSignal: new AbortController().signal });

const contentGenerator = config.getContentGenerator();
expect(contentGenerator.generateContent).toHaveBeenCalledWith(
Expand Down Expand Up @@ -194,7 +196,9 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Find the button',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.error).toBeDefined();
expect(result.llmContent).toContain('Failed to capture screenshot');
Expand All @@ -217,7 +221,9 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Check the layout',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.error).toBeDefined();
expect(result.llmContent).toContain('Visual model returned no analysis');
Expand All @@ -238,7 +244,9 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Find the red error',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.error).toBeDefined();
expect(result.llmContent).toContain(
Expand All @@ -261,7 +269,9 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Identify the element',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.error).toBeDefined();
expect(result.llmContent).toContain(
Expand All @@ -281,7 +291,9 @@ describe('analyzeScreenshot', () => {
const invocation = tool.build({
instruction: 'Find something',
});
const result = await invocation.execute(new AbortController().signal);
const result = await invocation.execute({
abortSignal: new AbortController().signal,
});

expect(result.error).toBeDefined();
expect(result.llmContent).toContain('Visual analysis failed');
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/agents/browser/analyzeScreenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
Kind,
type ToolResult,
type ToolInvocation,
type ExecuteOptions,
} from '../../tools/tools.js';
import { Environment } from '@google/genai';
import type { MessageBus } from '../../confirmation-bus/message-bus.js';
Expand Down Expand Up @@ -80,7 +81,7 @@ class AnalyzeScreenshotInvocation extends BaseToolInvocation<
return `Visual analysis: "${instruction}"`;
}

async execute(signal: AbortSignal): Promise<ToolResult> {
async execute({ abortSignal: signal }: ExecuteOptions): Promise<ToolResult> {
try {
const instruction = String(this.params['instruction'] ?? '');

Expand Down
Loading
Loading