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
JavaScript@langchain/corecallbacksbaseCallbackHandlerMethods
Interfaceā—Since v1.0

CallbackHandlerMethods

Base interface for callbacks. All methods are optional. If a method is not implemented, it will be ignored. If a method is implemented, it will be called at the appropriate time. All methods are called with the run ID of the LLM/ChatModel/Chain that is running, which is generated by the CallbackManager.

Copy
interface CallbackHandlerMethods

Methods

method
handleAgentAction→ void | Promise<void>

Called when an agent is about to execute an action, with the action and the run ID.

method
handleAgentEnd→ void | Promise<void>

Called when an agent finishes execution, before it exits. with the final output and the run ID.

method
handleChainEnd→ any

Called at the end of a Chain run, with the outputs and the run ID.

method
handleChainError→ any

Called if a Chain run encounters an error

method
handleChainStart→ any

Called at the start of a Chain run, with the chain name and inputs and the run ID.

method
handleChatModelStart→ any

Called at the start of a Chat Model run, with the prompt(s) and the run ID.

method
handleCustomEvent→ any
method
handleLLMEnd→ any

Called at the end of an LLM/ChatModel run, with the output and the run ID.

method
handleLLMError→ any

Called if an LLM/ChatModel run encounters an error

method
handleLLMNewToken→ any

Called when an LLM/ChatModel in streaming mode produces a new token

method
handleLLMStart→ any

Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.

method
handleRetrieverEnd→ any
method
handleRetrieverError→ any
method
handleRetrieverStart→ any
method
handleText→ void | Promise<void>
method
handleToolEnd→ any

Called at the end of a Tool run, with the tool output and the run ID.

method
handleToolError→ any

Called if a Tool run encounters an error

method
handleToolStart→ any

Called at the start of a Tool run, with the tool name and input and the run ID.

View source on GitHub