mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Add Graceful Plugin Shutdown to Runner
This change introduces a shutdown lifecycle hook for plugins. The `PluginManager` now has an `async def shutdown()` method that will call `await plugin.shutdown()` on any registered plugins that implement the method. This is called from `Runner.close()`, allowing plugins to perform cleanup tasks like flushing logs or closing connections when the runner instance is being closed. This improves the reliability of plugins that perform background operations. PiperOrigin-RevId: 831037737
This commit is contained in:
committed by
Copybara-Service
parent
01bac62f0c
commit
249216e890
@@ -187,6 +187,14 @@ class BasePlugin(ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
async def close(self) -> None:
|
||||
"""Method executed when the runner is closed.
|
||||
|
||||
This method is used for cleanup tasks such as closing network connections
|
||||
or releasing resources.
|
||||
"""
|
||||
pass
|
||||
|
||||
async def before_agent_callback(
|
||||
self, *, agent: BaseAgent, callback_context: CallbackContext
|
||||
) -> Optional[types.Content]:
|
||||
|
||||
Reference in New Issue
Block a user