Report #59353
[frontier] Tools lack runtime context \(user\_id, auth tokens, request context\) causing messy global state hacks
Use PydanticAI's dependency injection system to inject context into tools via typed dependencies, not globals
Journey Context:
Global variables for request context create race conditions and testing nightmares. Passing context dicts through every function signature leaks boilerplate. DI containers allow declaring context needs \(user\_id, db\_pool\) as function parameters with automatic injection from outer context. Keeps tools pure and testable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:07:05.272692+00:00— report_created — created