refactor(core): consolidate execute() arguments into ExecuteOptions (#25101)

This commit is contained in:
Michael Bleigh
2026-04-10 10:11:17 -07:00
committed by GitHub
parent 1d36309f5f
commit 3b7c17a22c
69 changed files with 849 additions and 527 deletions
@@ -187,7 +187,10 @@ describe('LocalSubagentInvocation', () => {
};
mockExecutorInstance.run.mockResolvedValue(mockOutput);
const result = await invocation.execute(signal, updateOutput);
const result = await invocation.execute({
abortSignal: signal,
updateOutput,
});
expect(MockLocalAgentExecutor.create).toHaveBeenCalledWith(
testDefinition,
@@ -224,7 +227,10 @@ describe('LocalSubagentInvocation', () => {
};
mockExecutorInstance.run.mockResolvedValue(mockOutput);
const result = await invocation.execute(signal, updateOutput);
const result = await invocation.execute({
abortSignal: signal,
updateOutput,
});
const display = result.returnDisplay as SubagentProgress;
expect(display.isSubagentProgress).toBe(true);
@@ -254,7 +260,7 @@ describe('LocalSubagentInvocation', () => {
return { result: 'Done', terminate_reason: AgentTerminateMode.GOAL };
});
await invocation.execute(signal, updateOutput);
await invocation.execute({ abortSignal: signal, updateOutput });
expect(updateOutput).toHaveBeenCalledTimes(4); // Initial + 2 updates + Final completion
const lastCall = updateOutput.mock.calls[3][0] as SubagentProgress;
@@ -293,7 +299,7 @@ describe('LocalSubagentInvocation', () => {
return { result: 'Done', terminate_reason: AgentTerminateMode.GOAL };
});
await invocation.execute(signal, updateOutput);
await invocation.execute({ abortSignal: signal, updateOutput });
const calls = updateOutput.mock.calls;
const lastCall = calls[calls.length - 1][0] as SubagentProgress;
@@ -326,7 +332,7 @@ describe('LocalSubagentInvocation', () => {
return { result: 'Done', terminate_reason: AgentTerminateMode.GOAL };
});
await invocation.execute(signal, updateOutput);
await invocation.execute({ abortSignal: signal, updateOutput });
expect(updateOutput).toHaveBeenCalledTimes(4); // Initial + 2 updates + Final completion
const lastCall = updateOutput.mock.calls[3][0] as SubagentProgress;
@@ -360,7 +366,7 @@ describe('LocalSubagentInvocation', () => {
return { result: 'Done', terminate_reason: AgentTerminateMode.GOAL };
});
await invocation.execute(signal, updateOutput);
await invocation.execute({ abortSignal: signal, updateOutput });
expect(updateOutput).toHaveBeenCalled();
const lastCall = updateOutput.mock.calls[
@@ -404,7 +410,7 @@ describe('LocalSubagentInvocation', () => {
};
});
await invocation.execute(signal, updateOutput);
await invocation.execute({ abortSignal: signal, updateOutput });
expect(updateOutput).toHaveBeenCalledTimes(4);
const lastCall = updateOutput.mock.calls[3][0] as SubagentProgress;
@@ -433,7 +439,7 @@ describe('LocalSubagentInvocation', () => {
});
// Execute without the optional callback
const result = await invocation.execute(signal);
const result = await invocation.execute({ abortSignal: signal });
expect(result.error).toBeUndefined();
const display = result.returnDisplay as SubagentProgress;
expect(display.isSubagentProgress).toBe(true);
@@ -445,7 +451,10 @@ describe('LocalSubagentInvocation', () => {
const error = new Error('Model failed during execution.');
mockExecutorInstance.run.mockRejectedValue(error);
const result = await invocation.execute(signal, updateOutput);
const result = await invocation.execute({
abortSignal: signal,
updateOutput,
});
expect(result.error).toBeUndefined();
expect(result.llmContent).toBe(
@@ -466,7 +475,10 @@ describe('LocalSubagentInvocation', () => {
const creationError = new Error('Failed to initialize tools.');
MockLocalAgentExecutor.create.mockRejectedValue(creationError);
const result = await invocation.execute(signal, updateOutput);
const result = await invocation.execute({
abortSignal: signal,
updateOutput,
});
expect(mockExecutorInstance.run).not.toHaveBeenCalled();
expect(result.error).toBeUndefined();
@@ -487,10 +499,10 @@ describe('LocalSubagentInvocation', () => {
mockExecutorInstance.run.mockRejectedValue(abortError);
const controller = new AbortController();
const executePromise = invocation.execute(
controller.signal,
const executePromise = invocation.execute({
abortSignal: controller.signal,
updateOutput,
);
});
controller.abort();
await expect(executePromise).rejects.toThrow('Aborted');
@@ -507,9 +519,9 @@ describe('LocalSubagentInvocation', () => {
};
mockExecutorInstance.run.mockResolvedValue(mockOutput);
await expect(invocation.execute(signal, updateOutput)).rejects.toThrow(
'Operation cancelled by user',
);
await expect(
invocation.execute({ abortSignal: signal, updateOutput }),
).rejects.toThrow('Operation cancelled by user');
});
it('should publish SUBAGENT_ACTIVITY events to the MessageBus', async () => {
@@ -529,7 +541,7 @@ describe('LocalSubagentInvocation', () => {
return { result: 'Done', terminate_reason: AgentTerminateMode.GOAL };
});
await invocation.execute(signal, updateOutput);
await invocation.execute({ abortSignal: signal, updateOutput });
expect(mockMessageBus.publish).toHaveBeenCalledWith(
expect.objectContaining({