LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentstypesDeepAgent
Interface●Since v1.4

DeepAgent

Copy
interface DeepAgent

Bases

ReactAgent<TTypes>

Properties

Methods

View source on GitHub

Example

Copy
const agent: DeepAgent<DeepAgentTypeConfig<...>> = createDeepAgent({ ... });

// Access subagent types for streaming
type Subagents = InferDeepAgentSubagents<typeof agent>;
property
~deepAgentTypes: TTypes

Type brand for DeepAgent type inference

property
options: CreateAgentParams<TTypes["Response"], TTypes["State"], TTypes["Context"]>
property
streamEvents: (state: InvokeStateParameter<TTypes>, config: InvokeConfiguration<InferContextInput<TTypes["Context"] extends InteropZodObject | AnyAnnotationRoot ? any[any] : AnyAnnotationRoot> & InferMiddlewareContextInputs<TTypes["Middleware"]>> & __type) => Promise<DeepAgentRunStream<Awaited<InferSchemaValue<TTypes["State"]> & TTypes["Response"] extends ResponseFormatUndefined ? Omit<BuiltInState<MessageStructure<ToolsToMessageToolSet<...>>>, "jumpTo"> : Omit<BuiltInState<MessageStructure<...>>, "jumpTo"> & __type & InferMiddlewareStates<TTypes["Middleware"]>>, readonly [TTypes["Tools"], BuiltinToolPlaceholder<"write_todos"> | BuiltinToolPlaceholder<"ls"> | BuiltinToolPlaceholder<"read_file"> | BuiltinToolPlaceholder<"write_file"> | BuiltinToolPlaceholder<"edit_file"> | BuiltinToolPlaceholder<"glob"> | BuiltinToolPlaceholder<"grep"> | BuiltinToolPlaceholder<"execute"> | BuiltinToolPlaceholder<"task"> | BuiltinToolPlaceholder<"start_async_task"> | BuiltinToolPlaceholder<"check_async_task"> | BuiltinToolPlaceholder<"update_async_task"> | BuiltinToolPlaceholder<"cancel_async_task"> | BuiltinToolPlaceholder<"list_async_tasks">], TTypes["Subagents"], InferDeepAgentStreamExtensions<TTypes["StreamTransformers"]>>> & (state: InvokeStateParameter<TTypes>, config: InvokeConfiguration<InferContextInput<TTypes["Context"] extends InteropZodObject | AnyAnnotationRoot ? any[any] : AnyAnnotationRoot> & InferMiddlewareContextInputs<TTypes["Middleware"]>> & __type) => Promise<AgentRunStream<MergedAgentState<TTypes>, TTypes["Tools"], InferStreamExtensions<TTypes["StreamTransformers"]>>>
property
checkpointer: boolean | BaseCheckpointSaver<number>

Optional checkpointer for persisting agent state between runs

property
graph
property
store: BaseStore

Optional BaseStore for persistent cross-conversation storage

method
drawMermaid
method
drawMermaidPng
method
invoke
method
stream
method
withConfig

DeepAgent extends ReactAgent with additional subagent type information.

This type wraps ReactAgent but includes the DeepAgentTypeConfig which contains subagent types for type-safe streaming and delegation.

Executes the agent with the v3 streaming interface, returning an DeepAgentRunStream that provides ergonomic, typed projections for messages, tool calls, subagents, and middleware events.

Pass version: "v3" to opt into this projection-oriented stream. Omitting version preserves the legacy internal LangGraph event-stream behavior for compatibility with LangGraph Platform integrations.

This v3 stream is experimental and its API may change in future releases. It will become the default in a future major release.

Copy
const run = await agent.streamEvents(
  {
    messages: [{ role: "user", content: "What's the weather in Paris?" }],
  },
  { version: "v3" }
);

// Stream all messages
for await (const msg of run.messages) {
  for await (const token of msg.text) {
    process.stdout.write(token);
  }
}

// Observe tool calls
for await (const call of run.toolCalls) {
  console.log(`Tool: ${call.name}`, call.input);
  console.log(`Result:`, await call.output);
}

// Observe subagent delegations
for await (const subagent of run.subagents) {
  console.log(`Subagent: ${subagent.name}`);

  for await (const msg of subagent.messages) {
    for await (const token of msg.text) {
      process.stdout.write(token);
    }
  }
}

// Get final state
const state = await run.output;