-
Notifications
You must be signed in to change notification settings - Fork 618
Plugin callbacks not propagated to sub-agent runners in agenttool #669
Copy link
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Bug
When a Plugin is registered on a Runner via PluginConfig, its callbacks (BeforeToolCallback, AfterToolCallback, etc.) do not fire for tools executed inside a sub-agent invoked via agenttool.
Root Cause
agenttool.Run() creates a new runner.Runner at agent_tool.go:170-177 without forwarding PluginConfig:
r, err := runner.New(runner.Config{
AppName: t.agent.Name(),
Agent: t.agent,
SessionService: sessionService,
ArtifactService: artifact.InMemoryService(),
MemoryService: memory.InMemoryService(),
// PluginConfig not set — sub-runner has no plugins
})The parent runner stores its plugin manager in context at runner.go:160:
ctx = plugininternal.ToContext(ctx, r.pluginManager)The sub-runner's Run() then overwrites the parent's plugin manager with its own empty one at the same line. The parent's plugins are lost.
Impact
- Observability plugins (logging, tracing, metrics) are blind to tool calls inside sub-agents
BeforeToolCallback/AfterToolCallbackonly fire for theagenttoolwrapper itself, not for function tools inside the sub-agent- Same issue affects
RunLive()(line 337)
Reproduction
- Create a parent agent with a sub-agent wrapped via
agenttool.New() - Sub-agent has a function tool (e.g.,
functiontool.New(...)) - Register a plugin with
BeforeToolCallbackon the parent runner - Run the parent agent with input that triggers delegation to the sub-agent
- Observe: plugin callback fires for
tool=sub_agent_namebut NOT for the inner function tool
Suggested Fix
Add a HasPlugins() method to PluginManager and make runner.Run() / runner.RunLive() conditional:
// runner.go:160 (and :337 for RunLive)
// Only overwrite if this runner has its own plugins — otherwise inherit parent's
if r.pluginManager.HasPlugins() {
ctx = plugininternal.ToContext(ctx, r.pluginManager)
}This preserves backwards compatibility: sub-runners with explicit plugins override; sub-runners without plugins (agenttool case) inherit the parent's.
Related
- Same issue reported in adk-python: Plugins don't run in AgentTool adk-python#2809, Custom Invocation Context propogation when using AgentTool adk-python#1746
- The
TODOcomments inagent_tool.go(lines 174, 200) suggest forwarding services is planned but not yet implemented
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working