PrintingHandler to capture LangChain callback events without manually instrumenting every call site.
Set up the handler
callback_handler to your runnable or agent callback configuration.
What gets logged
The handler listens to standard callback hooks, including:- LLM and chat model lifecycle (
start,end,error) - chain lifecycle (
start,end,error) - tool lifecycle (
start,end,error) - agent actions and finish events
- retriever lifecycle (
start,end,error) - text and retry events
Event category mapping
The handler normalizes callback names into category-styleevent_type values.Example:
llm_start and llm_end are stored as llm.
Root-chain trigger behavior
When a root chain ends (or errors), the handler can trigger:POST {trigger_url}/catch_route_manual- query params:
user_idandtrace_id
dev_mode=True to disable this external trigger while testing locally.
Get your nexus_api_key from the Nexus platform: Nexus platform.
Best practices
- Reuse one
NexusClientfor one logical run. - Keep
dev_mode=Truein local and CI environments. - Treat trigger endpoints as production infrastructure and monitor failures.