๊ฐ€์ž… ํ›„ ์ดˆ๋Œ€ ๋งํฌ๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋™์˜์ƒ ์žฌ์ƒ ๋ฐ ์ดˆ๋Œ€ ๋ณด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
๊ฐ€์ž… May 2026
280 ํŒ”๋กœ์ž‰ ์ค‘    415 ํŒฌ
# Useful but Little-Known Features of ADK 2.0 ๐ŸŒ What if you could hook into the entire agent execution lifecycle โ€” observing, intervening, and amending โ€” without touching agent code? ADK 2.0's Plugin system lets you extend `BasePlugin` and register it on a Runner to apply lifecycle callbacks globally across all agents. Unlike per-agent callbacks, plugins operate at the runner level with cross-cutting scope. ๐Ÿ“Œ Title: Plugins ๐Ÿ”— URL: ๐Ÿงฉ Overview Plugins extend `BasePlugin` and are registered on the Runner. Unlike agent-specific callbacks, they apply globally across all agents. Lifecycle hooks cover the full span: user message receipt, runner start, agent execution, model calls, tool execution, event processing, and runner end. Plugins operate in three modes: Observe (monitoring only), Intervene (modify or block processing), and Amend (modify results after the fact). Plugin callbacks run BEFORE agent callbacks in the execution order. ๐Ÿ›  How to use it Extend `BasePlugin` and override the lifecycle hooks you need. ```python from adk.plugins import BasePlugin class LoggingPlugin(BasePlugin): def __init__(self): super().__init__(name="logging_plugin") async def on_before_model_call(self, callback_context, llm_request): print(f"Model call: {llm_request.model}") return None # returning None continues normal processing async def on_after_tool_call(self, tool_context, tool_response): print(f"Tool executed: {tool_context.tool_name}") return None # Register on Runner runner = Runner( agent=my_agent, plugins=[LoggingPlugin()] ) ``` In Intervene mode, return a value from the callback to replace the normal processing. In Amend mode, modify results after event processing. ๐Ÿ— Building it into production ใƒปImplement logging and metrics collection as Observe-mode plugins to keep agent code clean ใƒปBuild guardrails and content filtering as Intervene-mode plugins to block inappropriate I/O ใƒปAdd analytics data collection as Amend-mode post-processing ใƒปLeverage prebuilt plugins (Reflect/Retry, BigQuery Analytics, Context Filtering, Global Instructions) to accelerate development ๐Ÿ’ก Use cases ๐Ÿ“Š Log all model calls and tool executions across every agent to BigQuery ๐Ÿ›ก Centralize input guardrails in a plugin to block harmful requests system-wide ๐Ÿ”„ Implement retry logic for failed model calls using the Reflect/Retry plugin ๐Ÿ“‹ Apply global instructions (compliance rules, etc.) to all agents via the Global Instructions plugin โš ๏ธ Watch out Plugin callbacks execute before agent callbacks โ€” if a plugin blocks processing, the agent callback won't fire. Returning incorrect values in Intervene mode can break agent behavior, so understand the expected return types and semantics before using it. Plugin execution order depends on registration order in the Runner. โœจ Plugins let you separate cross-cutting concerns (logging, security, analytics) from agent core logic, enabling highly maintainable systems. #ADK# #AIAgent#
๋” ๋ณด๊ธฐ