Repository navigation
feat: add plugin framework #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mykytanetipa
wants to merge
13
commits into
main
Choose a base branch
from
feat/a2a-plugins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ac25825
feat(plugins): add plugin interfaces, hook types and SequentialPlugin…
mykytanetipa 5b896c1
feat(server): run plugin hooks in DefaultRequestHandlerV2
mykytanetipa 114e781
feat(client): run plugin hooks in BaseClient
mykytanetipa 8a22fbf
test: cover plugins over JSON-RPC, HTTP+JSON, gRPC and v0.3
mykytanetipa 07b8ae0
refactor(server): merge plugin and default push delivery paths
mykytanetipa 7912da8
refactor: drop telemetry-only transport metadata from the plugin PR
mykytanetipa f50a7fc
refactor(client): pass plugin RPC names at each call site
mykytanetipa d8ab490
refactor(server): let the push sender own its plugin manager
mykytanetipa 1b310a9
Merge branch 'main' into feat/a2a-plugins
mykytanetipa a6ed492
refactor(plugins): rename server and client hooks
mykytanetipa 13505d5
chore: allow PLW in spell check
mykytanetipa 1a0c5b9
Merge branch 'main' into feat/a2a-plugins
mykytanetipa 7f0c242
refactor(plugins): use the client method names for plugin hooks
mykytanetipa 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
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
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 |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """Plugins: hooks into the A2A client and `DefaultRequestHandlerV2`. | ||
|
|
||
| Example: | ||
| from a2a import plugins | ||
|
|
||
| class TaskAudit(plugins.TaskObserverPlugin): | ||
| name = 'task-audit' | ||
|
|
||
| async def on_task_event(self, info: plugins.TaskEventInfo) -> None: | ||
| print(info.task_id, info.from_state, '->', info.to_state) | ||
|
|
||
| plugins.set_global(plugins.sequential(TaskAudit())) | ||
| # Create DefaultRequestHandlerV2 and clients after this point. | ||
| """ | ||
|
|
||
| from a2a.plugins.base import ( | ||
| ClientPlugin, | ||
| CompletePlugin, | ||
| ExecutionPlugin, | ||
| Plugin, | ||
| PushPlugin, | ||
| ServerPlugin, | ||
| TaskObserverPlugin, | ||
| ) | ||
| from a2a.plugins.manager import ( | ||
| PluginManager, | ||
| SequentialPluginManager, | ||
| get_global, | ||
| sequential, | ||
| set_global, | ||
| ) | ||
| from a2a.plugins.types import ( | ||
| ClientRequest, | ||
| ClientResponse, | ||
| PushRequest, | ||
| PushResult, | ||
| ServerRequest, | ||
| ServerResponse, | ||
| TaskEventInfo, | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| 'ClientPlugin', | ||
| 'ClientRequest', | ||
| 'ClientResponse', | ||
| 'CompletePlugin', | ||
| 'ExecutionPlugin', | ||
| 'Plugin', | ||
| 'PluginManager', | ||
| 'PushPlugin', | ||
| 'PushRequest', | ||
| 'PushResult', | ||
| 'SequentialPluginManager', | ||
| 'ServerPlugin', | ||
| 'ServerRequest', | ||
| 'ServerResponse', | ||
| 'TaskEventInfo', | ||
| 'TaskObserverPlugin', | ||
| 'get_global', | ||
| 'sequential', | ||
| 'set_global', | ||
| ] |
Oops, something went wrong.
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.
We should consider defining a path for coexistence of plugins and interceptors. I believe long term we should have only plugins as interceptors are subset in terms of functionality and hooks.
I think there is a gap with "early return" which we have in interceptors and don't have in plugins, which makes this convergence problematic so maybe we should cover this first. With this I hope it should be possible to implement interceptors invocations via plugins infrastructure via some adapter as an intermediate step until we can remove interceptors completely in favor of plugins as a breaking change. As a starting point we can deprecate
interceptorsparameter and recommend plugins. We also haveAuthInterceptorwhich we may consider porting to plugin via this adapter.(can be done as a separate PR)