LangChain integration
Trace LangChain chains, agents, retrievers and tools in Cloudmind with a callback handler.
JavaScript
import { CloudmindCallbackHandler } from "@cloudmind-ai/js/langchain";
const handler = new CloudmindCallbackHandler({
name: "support-chain",
metadata: { tenant: orgId },
});
await chain.invoke({ question }, { callbacks: [handler] });
Python
from cloudmind.langchain import CloudmindCallbackHandler
handler = CloudmindCallbackHandler(name="support-chain")
chain.invoke({"question": question}, config={"callbacks": [handler]})
What gets traced
| LangChain object | Cloudmind span kind |
|---|---|
LLM / ChatModel |
llm |
Retriever |
retrieval |
Tool |
tool |
Chain / Runnable |
custom |
AgentExecutor step |
custom |
Nesting follows LangChain's own callback tree, so the Cloudmind trace mirrors your chain structure.
Global handler
To trace everything without passing a handler at each call site:
import langchain
from cloudmind.langchain import CloudmindCallbackHandler
langchain.callbacks = [CloudmindCallbackHandler()]
LangGraph
LangGraph nodes are traced as nested spans automatically when the handler is attached to the compiled graph. Each node becomes a child span of the graph invocation, and conditional edges are recorded as span metadata so you can see which path a run took.