Skip to content
Merged
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
16 changes: 14 additions & 2 deletions packages/core/src/agents/a2a-client-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test that verifies that the timeout passed in is actually respected? particularly given we ware passing it in getting around the type system.

if (authHandler) {
fetchImpl = createAuthenticatingFetchWithRetry(fetch, authHandler);
fetchImpl = createAuthenticatingFetchWithRetry(a2aFetch, authHandler);
}

const resolver = new DefaultAgentCardResolver({ fetchImpl });
Expand Down
Loading