Skip to content

refactor(client)!: reorganize ClientFactory API#947

Merged
ishymko merged 6 commits into1.0-devfrom
ishymko/client-factory-refactor
Apr 9, 2026
Merged

refactor(client)!: reorganize ClientFactory API#947
ishymko merged 6 commits into1.0-devfrom
ishymko/client-factory-refactor

Conversation

@ishymko
Copy link
Copy Markdown
Member

@ishymko ishymko commented Apr 8, 2026

Replace connect class method with create_from_url instance method

  1. connect implies some persistent connection, in fact the only difference with create is I/O during agent card resolution (also optional, as it accepted both URL or agent card itself).
  2. Contained logic which was useful for a pre-configured factory instance (like agent card resolution).
  3. It's a separate async method and create is kept without I/O.

Added a utility create_client module function

One-line entry point similar to the former connect to simplify migration, but doesn't contain any domain logic and just does dispatching between URL and agent card.

@ishymko ishymko requested a review from a team as a code owner April 8, 2026 09:35
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

🧪 Code Coverage (vs 1.0-dev)

⬇️ Download Full Report

Base PR Delta
src/a2a/client/client_factory.py 89.31% 88.67% 🔴 -0.64%
Total 92.49% 92.48% 🔴 -0.01%

Generated by coverage-comment.yml

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the client creation logic by replacing the ClientFactory.connect class method with a standalone create_client convenience function and expanding the ClientFactory class with create and create_from_url methods. Corresponding updates were made across the codebase and test suites to adopt these changes. A minor improvement was suggested to optimize the ClientFactory.create method by caching the conversion of supported interfaces to a list, thereby avoiding redundant operations.

@ishymko ishymko force-pushed the ishymko/client-factory-refactor branch from 0f010ba to c452192 Compare April 8, 2026 09:53
@ishymko ishymko merged commit 01b3b2c into 1.0-dev Apr 9, 2026
18 checks passed
@ishymko ishymko deleted the ishymko/client-factory-refactor branch April 9, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants