Skip to content

feat: Add client plugin hooks in Client - #838

Merged
bartek-gralewicz merged 2 commits into
mainfrom
bgralewicz/client_call_hooks
Nov 19, 2026
Merged

bartek-gralewicz merged 2 commits into
mainfrom
bgralewicz/client_call_hooks

Conversation

@bartek-gralewicz

@bartek-gralewicz bartek-gralewicz commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Runs the client hooks from @a2a-js/sdk/plugins (#826) around every call Client makes to the server. Plugins are set with ClientConfig.plugins. ClientFactoryOptions.createFrom concatenates them, the same way it does interceptors.

const tracing: A2APlugin = {
  name: 'tracing',
  beforeClientRequest: (req) => {
    req.options.serviceParameters!['tracer'] = newTracer(); // Example name, not a part of the SDK
  },
};

const factory = new ClientFactory(
  ClientFactoryOptions.createFrom(ClientFactoryOptions.default, {
    clientConfig: { plugins: [tracing] },
  })
);

Notes

Since Server plugin side shared many similarities with the Client side, the common logic was extracted to the reused src/plugins/run.ts.

@bartek-gralewicz
bartek-gralewicz requested a review from a team as a code owner November 18, 2026 10:24
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

Base PR Delta
src/client/multitransport-client.ts 96.94% 98.05% 🟢 +1.11%
src/plugins/run.ts (new) — 100% —
Total 84.95% 85.04% 🟢 +0.09%

Generated by coverage-comment.yml

@JakubWorek JakubWorek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🚀

@bartek-gralewicz
bartek-gralewicz merged commit 337a003 into main Nov 19, 2026
20 checks passed
@bartek-gralewicz
bartek-gralewicz deleted the bgralewicz/client_call_hooks branch November 19, 2026 12:46
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