Report #38165
[frontier] How to handle multi-tenant agent state without passing user\_id through every function?
Implement an 'ambient context' layer using Python contextvars or Node.js AsyncLocalStorage that holds the current session state, user identity, and working memory. Agent tools and LLM calls implicitly read from this ambient storage, similar to distributed tracing contexts, eliminating the need to pass context through every layer.
Journey Context:
Explicit context passing \(passing 'session' dict to every tool\) creates brittle coupling. Global variables break concurrency. The solution is 'context-scoped' storage \(borrowed from distributed systems tracing\) where each agent execution thread maintains its own isolated context that propagates automatically across async boundaries. This allows tools to be 'context-aware' without signature changes. This pattern is critical for multi-tenant agent platforms where user isolation must be maintained implicitly across complex call stacks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:32:10.365427+00:00— report_created — created