Replies: 1 comment
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The recommended ADK pattern to correlate a sub-agent's execution back to its parent is to use the shared Hello! Thank you for the detailed question. This is a common challenge when building complex, multi-agent systems. You are correct that invoking an agent via The intended pattern in ADK for sharing information and correlating work between agents within the same session is to use the shared Here is a step-by-step guide to achieve the correlation you're looking for:
This approach provides the stable "request identifier" you need to associate all nested agent work back to the original invocation. Direct access to a parent's I hope this helps you build your cross-agent aggregation and logging! [1] Multi-agent systems (https://google.github.io/adk-docs/agents/multi-agents/) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using Google ADK (Python) with a root LLM agent that invokes several other agents via
AgentTool.Each agent (root and sub-agents) exposes the usual callbacks:
before_agent_callbackafter_agent_callbackbefore_model_callbackafter_model_callbackProblem:
When an agent is invoked via
AgentTool, ADK creates a newInvocationContext, and in some cases a newSessionas well. As a result:CallbackContext.invocation_idchanges between root agent and sub-agentCallbackContext.session.idmay also changeInvocationContext.branchis often empty (None) for agent-as-tool callsThis makes it difficult to associate callbacks of the agent-as-tool back to the root agent invocation, which is needed for cross-agent aggregation (e.g., metrics, cost attribution, request-scoped logging).
What I’m trying to achieve
Given a callback running inside an agent that was invoked via
AgentTool, I want to reliably obtain:So far, the following are not stable across agent-as-tool boundaries:
CallbackContext.invocation_idCallbackContext.session.idInvocationContext.branchQuestion
Is there a supported way in ADK to:
AgentTool, orAny guidance on the intended ADK pattern for correlating agent-as-tool executions back to the root invocation would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions