33from typing import Any , AsyncGenerator
44from uuid import uuid4
55
6+ from langchain_core .callbacks import BaseCallbackHandler
67from langchain_core .runnables .config import RunnableConfig
78from langgraph .errors import EmptyInputError , GraphRecursionError , InvalidUpdateError
89from langgraph .graph .state import CompiledStateGraph
@@ -41,6 +42,7 @@ def __init__(
4142 graph : CompiledStateGraph [Any , Any , Any , Any ],
4243 runtime_id : str | None = None ,
4344 entrypoint : str | None = None ,
45+ callbacks : list [BaseCallbackHandler ] | None = None ,
4446 ):
4547 """
4648 Initialize the runtime.
@@ -53,6 +55,7 @@ def __init__(
5355 self .graph : CompiledStateGraph [Any , Any , Any , Any ] = graph
5456 self .runtime_id : str = runtime_id or "default"
5557 self .entrypoint : str | None = entrypoint
58+ self .callbacks : list [BaseCallbackHandler ] = callbacks or []
5659 self .chat = UiPathChatMessagesMapper ()
5760 self ._middleware_node_names : set [str ] = self ._detect_middleware_nodes ()
5861
@@ -196,7 +199,7 @@ def _get_graph_config(self) -> RunnableConfig:
196199 """Build graph execution configuration."""
197200 graph_config : RunnableConfig = {
198201 "configurable" : {"thread_id" : self .runtime_id },
199- "callbacks" : [] ,
202+ "callbacks" : self . callbacks ,
200203 }
201204
202205 # Add optional config from environment
0 commit comments