LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScriptlangchainindexReactAgent
Interfaceā—Since v1.1

ReactAgent

ReactAgent is a production-ready ReAct (Reasoning + Acting) agent that combines language models with tools and middleware.

The agent is parameterized by a single type bag Types that encapsulates all type information:

Copy
interface ReactAgent

Example

Copy
// Using the type bag pattern
type MyTypes = AgentTypeConfig<
  { name: string },  // Response
  typeof myState,    // State
  typeof myContext,  // Context
  typeof middleware, // Middleware
  typeof tools       // Tools
>;

const agent: ReactAgent<MyTypes> = createAgent({ ... });

Properties

property
options: CreateAgentParams<Types["Response"], Types["State"], Types["Context"]>

The options to use for the tool output.

property
graph: AgentGraph<Types>

Methods

method
drawMermaid→ Promise<string>

Draw the graph as a Mermaid string.

method
drawMermaidPng→ Promise<Uint8Array<ArrayBuffer>>

Visualize the graph as a PNG image.

method
invoke→ Promise<ToolReturnType<TInput, TConfig, ToolOutputT>>

Invokes the tool with the provided input and configuration.

method
stream→ Promise<IterableReadableStream<ToolOutputT | ToolMessage<MessageStructure<MessageToolSet>>>>

Stream output in chunks.

method
withConfig→ Runnable<StructuredToolCallInput<SchemaT, SchemaInputT>, ToolOutputT | ToolMessage<MessageStructure<MessageToolSet>>, RunnableConfig<Record<string, any>>>

Bind config to a Runnable, returning a new Runnable.

View source on GitHub