Access Methods
The Context Facade provides two entry points, each returning a different manager type:Context::of()
Full agent access with configuration and callbacks receiving agent instances
Context::named()
Lightweight access using just an agent name string, ideal for admin tools
Choosing the Right Approach
Using Context::of()
The of() method (aliased as agent()) creates a ContextManager that requires a full agent class. This approach initializes a temporary agent instance internally, giving you access to agent configuration and the ability to work with agent instances in callbacks.
Filter Methods
All filter methods are chainable and create immutable instances (the original instance remains unchanged).Chaining Multiple Filters
Filters can be chained for complex queries (all filters are AND-ed together):Query Methods
Iteration Methods
Withof(), callbacks receive both the identity and the agent instance:
Action Methods
Using Context::named()
The named() method creates a NamedContextManager using just an agent name string. This lightweight approach doesn’t initialize any agent class—it only works with identities and requires explicit driver configuration.
Driver Configuration
Sincenamed() doesn’t have access to agent configuration, you must specify drivers explicitly:
If
withDrivers() is not called, the facade will attempt to use the default drivers from your config/laragent.php configuration.Filter Methods
The same filter methods are available, but callbacks only receive identities:Query Methods
Iteration Methods
Withnamed(), callbacks only receive the identity (no agent instance):
Action Methods
Action methods return counts instead of being chainable:Additional Methods
Filter Immutability
Filters create new instances, leaving the original unchanged. This allows building reusable query bases:Common Use Cases
Admin Dashboard - Clear Old Chats
Admin Dashboard - Clear Old Chats
User Account Deletion
User Account Deletion
Export User Chat History
Export User Chat History
Check Active Sessions
Check Active Sessions

