injectAgent

Retrieve the LangGraph-backed Agent from the current Angular injection context.

Mirrors @threadplane/ag-ui's injectAgent() so consumer code is identical regardless of which adapter is wired in app.config.ts. The agent is a singleton scoped to the injector that called provideAgent() — re-provide in a child component's providers: [] to scope a different agent to that subtree (Angular's hierarchical DI handles the rest).

Typed state via AgentRef. Pass the same ref that was supplied to provideAgent(ref, …) to carry the state type through DI without repeating the generic at every call site. The no-arg form defaults to LangGraphAgent<Record<string, unknown>>.

import { injectAgent } from '@threadplane/langgraph';

Declaration · overload 1

export declare function injectAgent(): LangGraphAgent<Record<string, unknown>>;

Returns

LangGraphAgent<Record<string, unknown>>

Examples

Typed state via AgentRef

const agent = injectAgent(TRIP); // LangGraphAgent<TripState>

Declaration · overload 2

export declare function injectAgent<T, ResolvedBag extends BagTemplate = BagTemplate>(ref: AgentRef<T>): LangGraphAgent<T, ResolvedBag>;

Type parameters

T
ResolvedBag
BagTemplate Default: BagTemplate

Parameters

ref · required
AgentRef<T>

Returns

LangGraphAgent<T, ResolvedBag>