Repository navigation
feat: Add plugin wrap call hooks to Client and Server plugins - #1491
Iwaniukooo11 merged 9 commits into
Conversation
🧪 Code Coverage (vs
|
| 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
a6957f3 to
318c02d
Compare
mykytanetipa
left a comment
There was a problem hiding this comment.
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 |
Description
This PR introduces
wrap_server_callandwrap_client_calland mounts that intoclientandserverpluginsExample use-cases are caching and retyring
Change
wrap_client_callandwrap_server_call.base_client(_execute_with_interceptorsand_execute_stream_with_interceptors_plugin_hooks(stream_wrapperandunary_wrapper)_Endmark at the end of a stream to distinguish it fromNoneresponsePlease 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.