@threadplane/langgraphInterfacev0.3.4

LangGraphAgent

Unified LangGraph agent surface returned by injectAgent().

Extends the runtime-neutral AgentWithHistory contract (chat-consumable) with the full LangGraph-specific API. One object drives both <chat> and any LangGraph-specific demo. Raw LangGraph signals are prefixed with langGraph to avoid collision with the runtime-neutral names.

import type { LangGraphAgent } from '@threadplane/langgraph';

Declaration

export interface LangGraphAgent<T = unknown, ResolvedBag extends BagTemplate = BagTemplate> extends AgentWithHistory<T>  {
  activeSubagents: Signal<SubagentStreamRef[]>;
  branch: Signal<string>;
  clientTools: ClientToolsCapability;
  customEvents: Signal<CustomStreamEvent[]>;
  experimentalBranchTree: Signal<AgentBranchTree<T>>;
  getMessagesMetadata: (msg: BaseMessage, idx?: number) => MessageMetadata<Record<string, unknown>> | undefined;
  getSubagent: (toolCallId: string) => SubagentStreamRef | undefined;
  getSubagentsByMessage: (msg: CoreAIMessage) => SubagentStreamRef[];
  getSubagentsByType: (type: string) => SubagentStreamRef[];
  getToolCalls: (msg: CoreAIMessage) => ToolCallWithResult[];
  hasValue: Signal<boolean>;
  interrupt: Signal<AgentInterrupt | undefined>;
  isThreadLoading: Signal<boolean>;
  joinStream: (runId: string, lastEventId?: string) => Promise<void>;
  langGraphHistory: Signal<ThreadState<T>[]>;
  langGraphInterrupts: Signal<Interrupt<ResolvedBag['InterruptType']>[]>;
  langGraphMessages: Signal<BaseMessage[]>;
  langGraphToolCalls: Signal<ToolCallWithResult[]>;
  lifecycle: AgentLifecycle;
  queue: Signal<AgentQueue>;
  regenerate: (assistantMessageIndex: number) => Promise<void>;
  reload: () => void;
  setBranch: (branch: string) => void;
  submit: (input: AgentSubmitInput | null | undefined, opts?: AgentSubmitOptions & LangGraphSubmitOptions) => Promise<void>;
  switchThread: (threadId: string | null) => void;
  toolProgress: Signal<ToolProgress[]>;
  value: Signal<T>;
}

Type parameters

T
Default: unknown
ResolvedBag
BagTemplate Default: BagTemplate

Members

activeSubagents

Filtered list of subagents with status 'running'.

activeSubagents: Signal<SubagentStreamRef[]>;

branch

Current branch identifier for time-travel navigation.

branch: Signal<string>;

clientTools

Client-declared, client-executed tools. Call setCatalog() to register tool specs; the catalog is automatically shipped with every run via input.client_tools. Pending tool calls appear in pending() after the run ends; resolve() returns a result and continues the run.

clientTools: ClientToolsCapability;

customEvents

Raw custom events stream (signal of array). The runtime-neutral events$ Observable is derived from this.

customEvents: Signal<CustomStreamEvent[]>;

experimentalBranchTree

Experimental branch tree derived from LangGraph checkpoint history.

experimentalBranchTree: Signal<AgentBranchTree<T>>;

getMessagesMetadata

Get metadata for a specific message by index.

getMessagesMetadata: (msg: BaseMessage, idx?: number) => MessageMetadata<Record<string, unknown>> | undefined;

getSubagent

Get a subagent stream by the tool call ID that spawned it.

getSubagent: (toolCallId: string) => SubagentStreamRef | undefined;

getSubagentsByMessage

Get subagent streams spawned by the tool calls on a specific AI message.

getSubagentsByMessage: (msg: CoreAIMessage) => SubagentStreamRef[];

getSubagentsByType

Get subagent streams by their configured subagent type/name.

getSubagentsByType: (type: string) => SubagentStreamRef[];

getToolCalls

Get tool call results associated with an AI message (LangGraph types).

getToolCalls: (msg: CoreAIMessage) => ToolCallWithResult[];

hasValue

True once at least one value or message has been received.

hasValue: Signal<boolean>;

interrupt

Current human-in-the-loop pause, or undefined when the run is not paused.

Narrowed from the neutral Agent contract, where interrupt is optional because a runtime without human-in-the-loop support omits it. The LangGraph adapter always provides it, so injectAgent().interrupt() type-checks directly under strictNullChecks — no ?.() needed.

interrupt: Signal<AgentInterrupt | undefined>;

isThreadLoading

True while a thread switch is loading state from the server.

isThreadLoading: Signal<boolean>;

joinStream

Join an already-running stream by run ID.

joinStream: (runId: string, lastEventId?: string) => Promise<void>;

langGraphHistory

Raw LangGraph history (ThreadState[]). Use history for AgentCheckpoint[].

langGraphHistory: Signal<ThreadState<T>[]>;

langGraphInterrupts

All interrupts received during the current run (raw LangGraph shape).

langGraphInterrupts: Signal<Interrupt<ResolvedBag['InterruptType']>[]>;

langGraphMessages

Raw LangChain BaseMessage list. Use messages for chat rendering.

langGraphMessages: Signal<BaseMessage[]>;

langGraphToolCalls

Raw LangGraph tool calls (with run-state). Use toolCalls for chat rendering.

langGraphToolCalls: Signal<ToolCallWithResult[]>;

lifecycle

Lifecycle signals for observability/telemetry. Eight read-only signals capture key transitions (first stream chunk, first interrupt, tool call start/complete, thread create/persist, errors). All reset on switchThread(). See AgentLifecycle.

lifecycle: AgentLifecycle;

queue

Pending server-side runs created via multitaskStrategy: 'enqueue'.

queue: Signal<AgentQueue>;

regenerate

Discards the assistant message at the given index AND all messages after it, then re-runs the agent against the trimmed conversation tail. The preceding user message (at index - 1) is preserved and re-submitted as the agent's input. No new user message is added to the history.

Throws if the message at index is not 'assistant' role, or if the agent is currently loading another response.

regenerate: (assistantMessageIndex: number) => Promise<void>;

reload

Re-submit the last input to restart the stream.

reload: () => void;

setBranch

Set the active branch for time-travel navigation.

setBranch: (branch: string) => void;

submit

Submit input, resume commands, checkpoint forks, or other LangGraph run options.

submit: (input: AgentSubmitInput | null | undefined, opts?: AgentSubmitOptions & LangGraphSubmitOptions) => Promise<void>;

switchThread

Switch to a different thread, resetting derived state.

switchThread: (threadId: string | null) => void;

toolProgress

Progress updates for currently executing tools.

toolProgress: Signal<ToolProgress[]>;

value

Current agent state values (raw, typed per the type parameter T).

value: Signal<T>;