Feat/retry fetch notifications (#21813)

This commit is contained in:
Aishanee Shah
2026-03-10 23:33:50 -04:00
committed by GitHub
parent 8b09ccc288
commit f8ad3a200a
24 changed files with 165 additions and 92 deletions
@@ -248,6 +248,7 @@ describe('WebFetchTool', () => {
getProxy: vi.fn(),
getGeminiClient: mockGetGeminiClient,
getRetryFetchErrors: vi.fn().mockReturnValue(false),
getMaxAttempts: vi.fn().mockReturnValue(3),
getDirectWebFetch: vi.fn().mockReturnValue(false),
modelConfigService: {
getResolvedConfig: vi.fn().mockImplementation(({ model }) => ({
+15
View File
@@ -31,6 +31,7 @@ import {
import { LlmRole } from '../telemetry/llmRole.js';
import { WEB_FETCH_TOOL_NAME } from './tool-names.js';
import { debugLogger } from '../utils/debugLogger.js';
import { coreEvents } from '../utils/events.js';
import { retryWithBackoff } from '../utils/retry.js';
import { WEB_FETCH_DEFINITION } from './definitions/coreTools.js';
import { resolveToolDeclaration } from './definitions/resolver.js';
@@ -186,6 +187,16 @@ class WebFetchToolInvocation extends BaseToolInvocation<
super(params, messageBus, _toolName, _toolDisplayName);
}
private handleRetry(attempt: number, error: unknown, delayMs: number): void {
coreEvents.emitRetryAttempt({
attempt,
maxAttempts: this.config.getMaxAttempts(),
delayMs,
error: error instanceof Error ? error.message : String(error),
model: 'Web Fetch',
});
}
private async executeFallback(signal: AbortSignal): Promise<ToolResult> {
const { validUrls: urls } = parsePrompt(this.params.prompt!);
// For now, we only support one URL for fallback
@@ -214,6 +225,8 @@ class WebFetchToolInvocation extends BaseToolInvocation<
},
{
retryFetchErrors: this.config.getRetryFetchErrors(),
onRetry: (attempt, error, delayMs) =>
this.handleRetry(attempt, error, delayMs),
},
);
@@ -423,6 +436,8 @@ ${textContent}
},
{
retryFetchErrors: this.config.getRetryFetchErrors(),
onRetry: (attempt, error, delayMs) =>
this.handleRetry(attempt, error, delayMs),
},
);