LangGraph
Adds instrumentation for LangGraph.
This integration requires SDK version 10.25.0 or higher.
Import name: Sentry.langChainIntegration
LangGraph is instrumented via the langChainIntegration, which automatically captures spans for LangGraph operations including agent invocations, graph executions, and node operations.
Copied
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
// Create LLM and agent
const llm = new ChatOpenAI({
modelName: "gpt-4o",
apiKey: process.env.OPENAI_API_KEY,
});
const agent = createReactAgent({ llm, tools: [] });
// Invoke the agent - automatically instrumented
const result = await agent.invoke({
messages: [
new SystemMessage("You are a helpful assistant."),
new HumanMessage("Hello!"),
],
});
For configuration options, runtime-specific setup, and detailed information, see the LangChain integration documentation.
@langchain/langgraph:>=0.2.0 <1.0.0
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").