← All docs

LangChain

One callback handler instruments every chain, tool, and model call.

Attach the Cisora callback handler once — every model call, tool call, and chain step is captured automatically across LangChain and LangGraph.

Install

npm install @cisora/sdk

Quickstart

import { ChatAnthropic } from '@langchain/anthropic';
import { CisoraCallbackHandler } from '@cisora/sdk/langchain';

const cisora = new CisoraCallbackHandler({
  apiKey: process.env.CISORA_API_KEY!,
  agentName: 'support-agent',
});

const model = new ChatAnthropic({
  model: 'claude-sonnet-4-5',
  callbacks: [cisora],
});

// Tools, chains, and graphs inherit the callback automatically.
await agentExecutor.invoke(
  { input: 'Summarize ticket #1234' },
  { callbacks: [cisora] }
);

What gets captured

  • Every llm_start / llm_end pair as a model_call
  • Every tool_start / tool_end pair as a tool action
  • Chain and graph nodes nested as parent/child spans in traces
  • session_id and run_id auto-propagated as trace_id
  • Token usage and cost extracted from provider responses

Notes

No code changes per call

Attaching the callback once at agent construction time is enough. You do not need to wrap every model or tool call individually.

Works alongside LangSmith

CisoraCallbackHandler is a standard LangChain BaseCallbackHandler. You can run it alongside LangSmith for evals — they capture different concerns.

Next steps