GlobalStorage is a thread-safe dictionary shared by all tools and middlewares during a single agent run. Use it to pass data between tool calls, track counters, or give middlewares access to information collected by tools.
Using global storage in tools
Addglobal_storage: GlobalStorage to your tool’s function signature. The framework injects it automatically at call time. Tools that don’t declare the parameter are unaffected.
Using global storage in middlewares
Access global storage from any middleware through the agent context:API reference
Common use cases
Cross-tool state
Track which tools have run, pass results from one tool to the next, or maintain a running count across the session.
Tracer / analytics access
A middleware sets up a tracer at the start of the run and stores it in global storage. Tools retrieve it by key to emit spans without any direct dependency on the middleware.
Deduplication
Record processed IDs so a tool can skip work it already did in the same run.
Shared configuration
Store runtime flags or user preferences once in
before_agent and read them anywhere without threading them through every function signature.Global storage is scoped to a single
agent.run() call. It is not persisted across separate runs or sessions. For cross-run persistence, use the session manager or an external store.