ADK Interception & Lifecycle (Python Edition)
Philosophy
Callbacks (Local) and Plugins (Global) allow for surgical interception of agent execution.
Logic Flow
- •Scope Determination:
- •Use Plugins for cross-cutting features (global logging, security policies).
- •Use Callbacks for agent-specific logic (task-dependent validation, hand-off).
- •Context Selection:
- •Load
references/hooks.mdfor hook signatures, context objects, and return types.
- •Load
- •Implementation:
- •Implement
before_*for validation/short-circuiting. - •Implement
after_*for post-processing/cleanup.
- •Implement
Output Standards
- •Explicit return types to signal intent (
Nonevs.types.Content/LlmResponse). - •Non-blocking async implementation.
- •Correct error handling via
on_*_errorhooks.