provideAgent()
provideAgent() registers the singleton agent configuration for every injectAgent() call in an Angular application. Call it once in bootstrapApplication or an ApplicationConfig to wire up the LangGraph API URL, assistant id, thread persistence, and transport.
injectAgent() itself takes no arguments โ all configuration flows through provideAgent().
#Configuration options
| Option | Type | Description |
|---|---|---|
apiUrl | string | LangGraph Platform API base URL. |
assistantId | string | LangGraph assistant id to bind to. |
threadId | () => string | undefined | Optional thread id provider, used to resume a persisted thread. |
onThreadId | (id: string) => void | Optional callback fired when a new thread id is assigned. |
transport | AgentTransport | Optional transport instance. Defaults to FetchStreamTransport when omitted. |
#Singleton model
A single provideAgent({...}) call configures the entire application. Every injectAgent() call resolves to the same configured agent.
#Test transports
transport is an object that implements AgentTransport, not an Angular class token. Create an instance before passing it to provideAgent().
Swap out the live transport for MockAgentTransport in tests by changing only
the transport field on provideAgent(). injectAgent() call sites stay
unchanged across environments.