Repository navigation
feat: add plugin interface - #572
Merged
Merged
Conversation
polchernikova-w
marked this pull request as ready for review
November 9, 2026 16:57
yarolegovich
approved these changes
Nov 10, 2026
polchernikova-w
added a commit
that referenced
this pull request
Nov 16, 2026
Adds the `a2aplugin` package, a hook-based layer on top of the plugin interface from #572 (re #538). Plugin authors fill in a struct of optional `Before*`/`After*`/`Wrap*` functions, and `a2aplugin.Server` / `a2aplugin.Client` turn them into an `a2asrv.Plugin` / `a2aclient.Plugin`. A nil field means the matching component isn't wrapped. ## What's added - **`ServerHooks`**: hooks for calls (`BeforeCall`, `AfterCall`, `WrapCall`), agent execution (`BeforeExecute`, `OnExecuteEvent`, `AfterExecute`, `WrapExecutor`), task store writes (`BeforeTaskWrite`, `AfterTaskWrite`, `WrapTaskStore`) and push deliveries (`BeforePush`, `AfterPush`, `WrapPushDelivery`). - **`ClientHooks`**: `BeforeCall`, `AfterCall` and `WrapCall`. - **`TaskWrite`**: describes a task store write (`Task`, `Event`, `PrevTask`). In each group, the `Wrap*` function wraps outside the `Before*`/`After*` hooks. `AfterExecute` receives the execution result and is called from the wrapper's `Cleanup`. ## Example `examples/plugins` now mixes both styles in one `WithPlugins` call: the server adds an `audit` plugin (call and task state logging), and the client adds an `experiments` plugin that sets a service param on every call. ## Testing Unit tests for every hook group: ordering against `Wrap*`, context propagation, early answers and errors from `Before*` hooks, response replacement in `AfterCall`, per-event `AfterCall` on streams, and service params isolation on client retries. I also ran the sample end to end.
ickeep
pushed a commit
to HuashiCloud/a2a-go
that referenced
this pull request
Nov 18, 2026
🤖 I have created a release *beep* *boop* --- ## [2.9.0](a2aproject/a2a-go@v2.8.0...v2.9.0) (2026-11-17) ### Features * **plugins:** extend clients and servers with `a2aclient.WithPlugins` and `a2asrv.WithPlugins`. Client plugins wrap calls; server plugins wrap calls, the agent executor, the task store and push delivery. The `a2aplugin` package builds plugins from hooks ([a2aproject#572](a2aproject#572), [a2aproject#581](a2aproject#581)) ([5216340](a2aproject@5216340), [b25d155](a2aproject@b25d155)) * **a2aclient/oauth:** OAuth 2.0 client support. `oauth.Manager` discovers authorization servers from agent cards and Protected Resource Metadata, signs users in (authorization code or device grant), and its plugin attaches and refreshes tokens ([a2aproject#568](a2aproject#568), [a2aproject#570](a2aproject#570)) ([c42999a](a2aproject@c42999a), [50dd177](a2aproject@50dd177)) * **a2aclient:** errors received from a server carry the response HTTP headers or gRPC metadata in `a2a.Error.ServiceParams` ([a2aproject#595](a2aproject#595)) ([d6a1d26](a2aproject@d6a1d26)) * **a2asrv:** pass the client's accepted output modes to agents in `ExecutorContext.AcceptedOutputModes` ([a2aproject#603](a2aproject#603)) ([57ee56c](a2aproject@57ee56c)) ### Behavior Changes * **a2asrv:** `SendMessage` and `SendStreamingMessage` return at most `Config.HistoryLength` messages of task history ([a2aproject#603](a2aproject#603)) ([57ee56c](a2aproject@57ee56c)) * **a2asrv:** `NewAgentCardEnforcer` rejects messages with a push config when the card doesn't support push notifications ([a2aproject#603](a2aproject#603)) ([57ee56c](a2aproject@57ee56c)) * **a2asrv:** a message reply gets the execution's contextId when the agent doesn't set one, and its taskId is cleared ([a2aproject#577](a2aproject#577), [a2aproject#609](a2aproject#609)) ([eee75ec](a2aproject@eee75ec), [97de334](a2aproject@97de334)) * **a2asrv:** getting a missing push config returns `TaskNotFound` instead of an internal error, and a REST push config delete returns `{}` ([a2aproject#578](a2aproject#578), [a2aproject#600](a2aproject#600)) ([ff3fcf8](a2aproject@ff3fcf8), [0d1ac2a](a2aproject@0d1ac2a)) * **a2aclient:** a JSON-RPC HTTP error without a JSON-RPC body is an `*a2a.Error` (`ErrUnauthenticated` for 401, `ErrUnauthorized` for 403, `ErrServerError` otherwise) instead of a plain error ([a2aproject#595](a2aproject#595)) ([d6a1d26](a2aproject@d6a1d26)) * **a2aclient:** stream responses of an unknown type are skipped instead of ending the stream with an error ([a2aproject#532](a2aproject#532)) ([212512b](a2aproject@212512b)) ### Bug Fixes * **a2a:** accept pointer OAuth flow types when marshalling ([a2aproject#541](a2aproject#541)) ([fe407e3](a2aproject@fe407e3)) * **a2aacp:** don't count exited agents in makeRoom ([a2aproject#563](a2aproject#563)) ([6b0c5bd](a2aproject@6b0c5bd)) * **a2aacp:** drop empty parts instead of sending a block without content ([a2aproject#594](a2aproject#594)) ([d8323ce](a2aproject@d8323ce)) * **a2aacp:** fail turns of a stopped agent with `AgentStoppedError` ([a2aproject#573](a2aproject#573)) ([4acb390](a2aproject@4acb390)) * **a2aacp:** release the context lock before reporting the end of a turn, so `RejectBusyContext` accepts the next message ([a2aproject#601](a2aproject#601)) ([964e814](a2aproject@964e814)) * **a2aacp:** reserve pool capacity during startup ([a2aproject#587](a2aproject#587)) ([621d73b](a2aproject@621d73b)) * **a2av0:** keep unset ListTasks history length unset ([a2aproject#527](a2aproject#527)) ([9b4435f](a2aproject@9b4435f)) * **pbconv:** leave an unset ListTasks page size unset ([a2aproject#576](a2aproject#576)) ([5a3d99d](a2aproject@5a3d99d)) * **sse:** support carriage-return event line endings ([a2aproject#487](a2aproject#487)) ([ecaea9c](a2aproject@ecaea9c)) * **taskexec:** don't end remote subscriptions at the caller's message ([a2aproject#575](a2aproject#575)) ([d0710f5](a2aproject@d0710f5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: Yaroslav Shevchuk <[email protected]>
This was referenced Nov 25, 2026
3 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds the core plugin interface for the server and the client. The hook-based
a2apluginhelper package will follow in a separate PR. (re #538).What's added
a2asrv.Plugin: wraps four handler components. Each method receives the next component and returns a wrapped one.a2aclient.Plugin:WrapCall(next CallHandler) CallHandler, wrapping every client call outside the interceptors.push.DeliveryHandler: delivers one push notification and reports the outcome.Also:
PassthroughPluginin both packages returns every component unchanged.WithPlugins(aRequestHandlerOptionon the server, aFactoryOptionon the client) adds to the plugins already set. The first plugin is the outermost wrapper.CallHandleris now exported in both packages.Example
examples/plugins: a server with atimingplugin that logs the duration of every call, including streams, and a client with aretryplugin forGetTask.Testing
Unit tests for each wrap point: ordering, retry, early answer, streaming, executor cleanup, task store reads and writes, push headers and skip, and plugins kept by
WithAdditionalOptions. I also ran the sample end to end.