mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 10:34:35 -07:00
fix(a2a): Don't throw errors for GeminiEventType Retry and InvalidStream. (#16541)
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
This commit is contained in:
@@ -349,6 +349,44 @@ describe('Task', () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
{ eventType: GeminiEventType.Retry, eventName: 'Retry' },
|
||||||
|
{ eventType: GeminiEventType.InvalidStream, eventName: 'InvalidStream' },
|
||||||
|
])(
|
||||||
|
'should handle $eventName event without triggering error handling',
|
||||||
|
async ({ eventType }) => {
|
||||||
|
const mockConfig = createMockConfig();
|
||||||
|
const mockEventBus: ExecutionEventBus = {
|
||||||
|
publish: vi.fn(),
|
||||||
|
on: vi.fn(),
|
||||||
|
off: vi.fn(),
|
||||||
|
once: vi.fn(),
|
||||||
|
removeAllListeners: vi.fn(),
|
||||||
|
finished: vi.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// @ts-expect-error - Calling private constructor
|
||||||
|
const task = new Task(
|
||||||
|
'task-id',
|
||||||
|
'context-id',
|
||||||
|
mockConfig as Config,
|
||||||
|
mockEventBus,
|
||||||
|
);
|
||||||
|
|
||||||
|
const cancelPendingToolsSpy = vi.spyOn(task, 'cancelPendingTools');
|
||||||
|
const setTaskStateSpy = vi.spyOn(task, 'setTaskStateAndPublishUpdate');
|
||||||
|
|
||||||
|
const event = {
|
||||||
|
type: eventType,
|
||||||
|
};
|
||||||
|
|
||||||
|
await task.acceptAgentMessage(event);
|
||||||
|
|
||||||
|
expect(cancelPendingToolsSpy).not.toHaveBeenCalled();
|
||||||
|
expect(setTaskStateSpy).not.toHaveBeenCalled();
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('_schedulerToolCallsUpdate', () => {
|
describe('_schedulerToolCallsUpdate', () => {
|
||||||
|
|||||||
@@ -707,6 +707,10 @@ export class Task {
|
|||||||
case GeminiEventType.ModelInfo:
|
case GeminiEventType.ModelInfo:
|
||||||
this.modelInfo = event.value;
|
this.modelInfo = event.value;
|
||||||
break;
|
break;
|
||||||
|
case GeminiEventType.Retry:
|
||||||
|
case GeminiEventType.InvalidStream:
|
||||||
|
// An invalid stream should trigger a retry, which requires no action from the user.
|
||||||
|
break;
|
||||||
case GeminiEventType.Error:
|
case GeminiEventType.Error:
|
||||||
default: {
|
default: {
|
||||||
// Block scope for lexical declaration
|
// Block scope for lexical declaration
|
||||||
|
|||||||
Reference in New Issue
Block a user