Skip to content
Closed
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
22 changes: 22 additions & 0 deletions packages/core/src/core/baseLlmClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,28 @@ describe('BaseLlmClient', () => {
);
});

it('should forward the caller-provided abortSignal to retryWithBackoff so the overall retry loop honors it', async () => {
const mockResponse = createMockResponse('This is the content.');
mockGenerateContent.mockResolvedValue(mockResponse);

const options = {
modelConfigKey: { model: 'test-model' },
contents: [{ role: 'user', parts: [{ text: 'Give me content.' }] }],
abortSignal: abortController.signal,
promptId: 'content-prompt-id',
role: LlmRole.UTILITY_TOOL,
};

await client.generateContent(options);

expect(retryWithBackoff).toHaveBeenCalledWith(
expect.any(Function),
expect.objectContaining({
signal: options.abortSignal,
}),
);
});

it('should validate content using shouldRetryOnContent function', async () => {
const mockResponse = createMockResponse('Some valid content.');
mockGenerateContent.mockResolvedValue(mockResponse);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core/baseLlmClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export class BaseLlmClient {
shouldRetryOnContent,
maxAttempts:
availabilityMaxAttempts ?? maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
signal: abortSignal,
getAvailabilityContext,
onPersistent429: this.config.isInteractive()
? (authType, error) =>
Expand Down