This repository was archived by the owner on Jun 3, 2026. It is now read-only.
Repository navigation
feat(a2a): add clientFactory to A2AAgent for auth support #806
Closed
agent-of-mkmeral
wants to merge
2
commits into
strands-agents:main
from
agent-of-mkmeral:feat/a2a-client-factory-options
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
|
|
||
| import type { AgentCard, Part } from '@a2a-js/sdk' | ||
| import type { Client as A2AClientSdk } from '@a2a-js/sdk/client' | ||
| import { ClientFactory } from '@a2a-js/sdk/client' | ||
| import { ClientFactory, ClientFactoryOptions } from '@a2a-js/sdk/client' | ||
| import type { InvokableAgent, InvokeArgs, InvokeOptions } from '../types/agent.js' | ||
| import { AgentResult } from '../types/agent.js' | ||
| import { Message, TextBlock, type ContentBlock, type ContentBlockData, type MessageData } from '../types/messages.js' | ||
|
|
@@ -31,6 +31,28 @@ export interface A2AAgentConfig { | |
| name?: string | ||
| /** Optional description. If not provided, populated from the agent card after connection. */ | ||
| description?: string | ||
| /** | ||
| * Options passed to the underlying A2A SDK {@link ClientFactory}. | ||
| * | ||
| * Use this to configure authentication, custom transports, interceptors, | ||
| * or a custom agent card resolver. Partial options are merged with the SDK | ||
| * defaults via `ClientFactoryOptions.createFrom`. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { DefaultAgentCardResolver, createAuthenticatingFetchWithRetry } from '@a2a-js/sdk/client' | ||
| * | ||
| * const agent = new A2AAgent({ | ||
| * url: 'https://protected-agent.example.com', | ||
| * clientFactoryOptions: { | ||
| * cardResolver: new DefaultAgentCardResolver({ | ||
| * fetchImpl: createAuthenticatingFetchWithRetry(fetch, myAuthHandler), | ||
| * }), | ||
| * }, | ||
| * }) | ||
| * ``` | ||
| */ | ||
| clientFactoryOptions?: Partial<ClientFactoryOptions> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Suggestion: Re-export export { ClientFactoryOptions } from '@a2a-js/sdk/client'This aligns with the "Prefer Flat Namespaces Over Nested Modules" decision record — users shouldn't need to import from transitive dependencies for common functionality. |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -170,7 +192,10 @@ export class A2AAgent implements InvokableAgent { | |
|
|
||
| logExperimentalWarning() | ||
|
|
||
| const factory = new ClientFactory() | ||
| const factoryOptions = this._config.clientFactoryOptions | ||
| const factory = factoryOptions | ||
| ? new ClientFactory(ClientFactoryOptions.createFrom(ClientFactoryOptions.default, factoryOptions)) | ||
| : new ClientFactory() | ||
| const client = await factory.createFromUrl(this._config.url, this._config.agentCardPath) | ||
| this._agentCard = await client.getAgentCard() | ||
| if (this.name === undefined && this._agentCard?.name) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: The
agentCardPathtest is in theclientFactoryOptionsdescribe block but doesn't actually testclientFactoryOptionsbehavior — it tests the existingagentCardPathconfig passthrough tocreateFromUrl. This makes the test grouping misleading.Suggestion: Move this test to a more appropriate describe block (e.g., the
identity propertiesorinvokeblock), or rename the describe to something broader likeclient configuration.