fix(core): set default maxAttempts in baseLLMClient (#9533)

This commit is contained in:
anthony bushong
2025-09-24 18:18:26 -07:00
committed by GitHub
parent 8abe7e151c
commit 275a12fd45
2 changed files with 6 additions and 2 deletions

View File

@@ -207,7 +207,7 @@ describe('BaseLlmClient', () => {
await client.generateJson(defaultOptions);
expect(retryWithBackoff).toHaveBeenCalledWith(expect.any(Function), {
maxAttempts: undefined,
maxAttempts: 5,
});
});
});

View File

@@ -19,6 +19,8 @@ import { logMalformedJsonResponse } from '../telemetry/loggers.js';
import { MalformedJsonResponseEvent } from '../telemetry/types.js';
import { retryWithBackoff } from '../utils/retry.js';
const DEFAULT_MAX_ATTEMPTS = 5;
/**
* Options for the generateJson utility function.
*/
@@ -105,7 +107,9 @@ export class BaseLlmClient {
promptId,
);
const result = await retryWithBackoff(apiCall, { maxAttempts });
const result = await retryWithBackoff(apiCall, {
maxAttempts: maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
});
let text = getResponseText(result)?.trim();
if (!text) {