fix: run on_event_callback before append_event to persist plugin modifications#5309
fix: run on_event_callback before append_event to persist plugin modifications#5309Jah-yee wants to merge 4 commits intogoogle:mainfrom
Conversation
Updates documentation for 'adk web' and 'adk api_server' commands to clarify
the multiple supported agent directory formats:
- {agent_name}/agent.py (module with root_agent)
- {agent_name}.py (module with root_agent)
- {agent_name}/__init__.py (package with root_agent or app)
- {agent_name}/root_agent.yaml (YAML config folder)
The implementation already supports all these formats via AgentLoader, but the docstring
only mentioned the YAML case, causing user confusion per issue google#4425.
Signed-off-by: RoomWithOutRoof <RoomWithOutRoof@users.noreply.github.com>
…fications Previously, on_event_callback was executed AFTER append_event, causing plugin modifications to events (e.g., custom_metadata) to only be visible in the real-time event stream but not persisted to the database. This fix reorders the execution so that: 1. on_event_callback runs first to modify the event 2. append_event stores the (possibly modified) event to DB 3. The event is then yielded to the client This ensures plugin modifications are persisted and visible when fetching conversation history. Fixes: google#3990
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Hello @Jah-yee, thank you for your contribution! Before we can merge this PR, could you please address the following:
This information will help us review and merge your PR more efficiently. Thanks! Response from ADK Triaging Agent |
|
Hi @Jah-yee , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you! |
Just signed! |
Good day
Summary
Fixes issue #3990 - the on_event_callback plugin hook was executing after the event had already been saved to the database via session_service.append_event(). This caused plugin modifications (e.g., adding/modifying custom_metadata) to only be visible in the yielded event stream but not persisted to the database.
Changes
Reorders execution in runners.py so that:
This ensures plugin modifications are persisted and visible when fetching conversation history.
Testing
Files Changed
感谢你们的奉献,希望能提供帮助。如果我解决得有问题或有待商妥的地方,请在下面留言,我会来处理。
Warmly,
RoomWithOutRoof