LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corecallbacksmanagerCallbackManager
    Class●Since v0.1

    CallbackManager

    Callback manager for LangChain.

    Copy
    CallbackManager(
      self,
      handlers: list[BaseCallbackHandler],
      inheritable_handlers: list[BaseCallbackHandler] | None = None,
      parent_run_id: UUID | None = None,
      *,
      tags: list[str] | None = None,
      inheritable_tags: list[str] | None = None,
      metadata: dict[str, Any] | None = None,
      inheritable_metadata: dict[str, Any] | None = None
    )

    Bases

    BaseCallbackManager

    Used in Docs

    • Gptrouter integration
    • Titan takeoff integration
    • Zhipu AI integration

    Methods

    method
    on_llm_start

    Run when LLM starts running.

    method
    on_chat_model_start

    Run when chat model starts running.

    method
    on_chain_start

    Run when chain starts running.

    method
    on_tool_start

    Run when tool starts running.

    method
    on_retriever_start

    Run when the retriever starts running.

    method
    on_custom_event

    Dispatch an adhoc event to the handlers (async version).

    This event should NOT be used in any internal LangChain code. The event is meant specifically for users of the library to dispatch custom events that are tailored to their application.

    method
    configure

    Configure the callback manager.

    Inherited fromBaseCallbackManager

    Attributes

    Ahandlers: handlersAinheritable_handlers: inheritable_handlersAparent_run_id: UUID | None
    —

    The ID of the parent run.

    Atags: list[str] | None
    —

    Optional list of tags associated with the retriever.

    Ainheritable_tagsAmetadata: dict[str, Any] | None
    —

    Optional metadata associated with the retriever.

    Ainheritable_metadataAis_async: bool
    —

    Return whether the handler is async.

    Methods

    Mcopy
    —

    Return a copy of the edge with optional new source and target nodes.

    Mmerge
    —

    Merge the group callback manager with another callback manager.

    Madd_handler
    —

    Add a handler to the callback manager.

    Mremove_handler
    —

    Remove a handler from the callback manager.

    Mset_handlers
    —

    Set handlers as the only handlers on the callback manager.

    Mset_handler
    —

    Set handler as the only handler on the callback manager.

    Madd_tags
    —

    Add tags to the callback manager.

    Mremove_tags
    —

    Remove tags from the callback manager.

    Madd_metadata
    —

    Add metadata to the callback manager.

    Mremove_metadata
    —

    Remove metadata from the callback manager.

    View source on GitHub