Hi!
I’m building a system using the Google Agent Developer Kit (ADK) framework that involves multiple sub-agents and their associated tools. My goal is to enable shared memory across the entire session, such that:
- Information retrieved or computed by one tool is accessible to other tools or agents later in the same session
- Repeated work (e.g. term definitions) can be cached and reused
- The overall system maintains consistent state across sub-agent boundaries
I’m using function-based tools with the ToolContext parameter and trying to write to tool_context.state. I’m encountering this error:
400 INVALID_ARGUMENT. {‘error’: {‘code’: 400, ‘message’: ‘Request contains an invalid argument.’, ‘status’: ‘INVALID_ARGUMENT’}}
Questions
- What are the recommended ways to share memory/state between tools and sub-agents within a session using Google ADK?
- How should I use
ToolContextorCallbackContextto safely and persistently read/write session state? - Are class-based tools preferred over function tools when interacting with shared session state?
- Could you provide any working code examples or architectural patterns that demonstrate shared memory across agents and tools (e.g., glossary terms, cached results, document metadata)?
Thanks!