OptionaltoolRegistry: ClientToolRegistryOptional pre-built tool registry. Defaults to a fresh empty registry.
Optionalprovider: IMetadataProviderOptional IMetadataProvider to bind this session to. Pass an explicit
provider when your app talks to multiple MJ servers in parallel; otherwise the session
falls back to Metadata.Provider (the global default), which is fine for single-server apps.
Emitted on agent progress updates during RunAgent / RunAgentFromConversationDetail
Emitted when an error occurs during tool execution or communication
Emitted when session state changes (true = active, false = stopped)
Emitted after a tool has been executed (with result)
Emitted when a tool request is received from the server (before execution)
Whether a session is currently active and listening for tool requests
The metadata provider this session uses. Falls back to the global Metadata.Provider
when no explicit provider was supplied.
The current session ID, or null if no session is active
The underlying tool registry
Add a client tool dynamically at runtime. Registers the handler locally and notifies the server.
Decorate base tools with runtime context and send definitions to the server.
Dispose the session: stop listening, complete all observables, and clear state. Call this when the session is no longer needed to prevent memory leaks.
Get all registered tool definitions.
Register a client-side tool. The consuming application calls this to make tools available for server-side agents to invoke. Re-registration is allowed (existing tool is replaced).
Register a decorator that enriches a metadata-driven tool with runtime context.
Remove a client tool at runtime.
Run an AI agent. Wraps GraphQLAIClient.RunAIAgent() with a simplified API.
Parameters for the agent run
The agent execution result
Run an AI agent from an existing conversation detail. This is the optimized path that loads conversation history server-side. Wraps GraphQLAIClient.RunAIAgentFromConversationDetail().
Parameters for the agent run
The agent execution result
Set the runtime context that decorators receive. Call this whenever context changes (user navigates, new data loads, etc.)
Start listening for client tool requests for a specific session. Subscribes to the GraphQL ClientToolRequest subscription via the data provider.
The agent session ID to listen for
Stop listening for client tool requests and clean up the session.
Unregister a client-side tool.
Manages a client session connected to an MJ agent.
Handles bidirectional communication via GraphQL:
All events are exposed as RxJS observables for framework-agnostic reactive consumption.
Example