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:
Emily Hedlund
2026-01-14 12:04:51 -05:00
committed by GitHub
parent dfb7dc7069
commit 764016bca7
2 changed files with 42 additions and 0 deletions

View File

@@ -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', () => {

View File

@@ -707,6 +707,10 @@ export class Task {
case GeminiEventType.ModelInfo:
this.modelInfo = event.value;
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:
default: {
// Block scope for lexical declaration