Skip to content

feat: Add plugin wrap call hooks to Client and Server plugins - #1491

Merged
Iwaniukooo11 merged 9 commits into
a2aproject:mainfrom
Iwaniukooo11:mateusziwaniuk/feat/plugin-wrap-call-hooks
Nov 19, 2026
Merged

Iwaniukooo11 merged 9 commits into
a2aproject:mainfrom
Iwaniukooo11:mateusziwaniuk/feat/plugin-wrap-call-hooks

Conversation

@Iwaniukooo11

Copy link
Copy Markdown
Member

Description

This PR introduces wrap_server_call and wrap_client_call and mounts that into client and server plugins
Example use-cases are caching and retyring

Change

  • Added two hooks: wrap_client_call and wrap_server_call.
  • Mounted it to base_client (_execute_with_interceptors and _execute_stream_with_interceptors
  • Mounted it to _plugin_hooks (stream_wrapper and unary_wrapper)
  • Also: added _End mark at the end of a stream to distinguish it from None response

Please note that the approach used was with having aclosing, not following the draft #1437.
The reason is that closing shouldn't run plugin code - That could fail and mask the real error that is already propagating.

Tests

Added client and server tests:
Hook order on unary, streaming and error paths, nesting order, and a plugin that raises instead of calling.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/client/base_client.py 96.69% 96.74% 🟢 +0.05%
src/a2a/server/cluster/database_event_stream.py 93.64% 97.27% 🟢 +3.64%
src/a2a/server/request_handlers/_plugin_hooks.py 94.83% 95.24% 🟢 +0.41%
src/a2a/plugins/_sentinels.py (new) — 100.00% —
Total 93.79% 93.85% 🟢 +0.06%

Generated by coverage-comment.yml

@Iwaniukooo11
Iwaniukooo11 force-pushed the mateusziwaniuk/feat/plugin-wrap-call-hooks branch from a6957f3 to 318c02d Compare November 18, 2026 10:34
@Iwaniukooo11
Iwaniukooo11 marked this pull request as ready for review November 18, 2026 10:38
@Iwaniukooo11
Iwaniukooo11 requested a review from a team as a code owner November 18, 2026 10:38

@mykytanetipa mykytanetipa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

go also added WrapExecutor, WrapTaskStore, WrapPushDelivery a2aproject/a2a-go#538

I think we should also consider adding them in Python. It's ok I think if you want to defer it to follow-up PRs, but in this case I'd rename the PR so it's clear we've scoped it out.

Comment thread src/a2a/client/base_client.py Resolved
Comment thread src/a2a/client/base_client.py Resolved
@Iwaniukooo11 Iwaniukooo11 changed the title feat: Add plugin wrap call hooks feat: Add plugin wrap call hooks to Client and Server plugins Nov 19, 2026
@Iwaniukooo11

Copy link
Copy Markdown
Member Author

go also added WrapExecutor, WrapTaskStore, WrapPushDelivery a2aproject/a2a-go#538

I think we should also consider adding them in Python. It's ok I think if you want to defer it to follow-up PRs, but in this case I'd rename the PR so it's clear we've scoped it out.

@mykytanetipa
I will provide the rest of wrappers in the follow up PRs.
i also changed the title of current PR so it's clear that we touch client and server only

@mykytanetipa mykytanetipa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Iwaniukooo11
Iwaniukooo11 merged commit 12b7847 into a2aproject:main Nov 19, 2026
21 checks passed
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