From 066b0cc15f3eaceabe9185f199862d755408bdb7 Mon Sep 17 00:00:00 2001 From: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:59:53 -0500 Subject: [PATCH] fix(core): increase A2A agent timeout to 30 minutes (#21028) --- packages/core/src/agents/a2a-client-manager.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core/src/agents/a2a-client-manager.ts b/packages/core/src/agents/a2a-client-manager.ts index 694905cdc5..e7070f3dfa 100644 --- a/packages/core/src/agents/a2a-client-manager.ts +++ b/packages/core/src/agents/a2a-client-manager.ts @@ -23,8 +23,20 @@ import { createAuthenticatingFetchWithRetry, } from '@a2a-js/sdk/client'; import { v4 as uuidv4 } from 'uuid'; +import { Agent as UndiciAgent } from 'undici'; import { debugLogger } from '../utils/debugLogger.js'; +// Remote agents can take 10+ minutes (e.g. Deep Research). +// Use a dedicated dispatcher so the global 5-min timeout isn't affected. +const A2A_TIMEOUT = 1800000; // 30 minutes +const a2aDispatcher = new UndiciAgent({ + headersTimeout: A2A_TIMEOUT, + bodyTimeout: A2A_TIMEOUT, +}); +const a2aFetch: typeof fetch = (input, init) => + // @ts-expect-error The `dispatcher` property is a Node.js extension to fetch not present in standard types. + fetch(input, { ...init, dispatcher: a2aDispatcher }); + export type SendMessageResult = | Message | Task @@ -79,9 +91,9 @@ export class A2AClientManager { throw new Error(`Agent with name '${name}' is already loaded.`); } - let fetchImpl: typeof fetch = fetch; + let fetchImpl: typeof fetch = a2aFetch; if (authHandler) { - fetchImpl = createAuthenticatingFetchWithRetry(fetch, authHandler); + fetchImpl = createAuthenticatingFetchWithRetry(a2aFetch, authHandler); } const resolver = new DefaultAgentCardResolver({ fetchImpl });