langchain
e2da1459 - perf(core): optimize callback manager hot paths

Commit
94 days ago
perf(core): optimize callback manager hot paths - get_child(): pass state directly to constructor instead of calling set_handlers/add_tags/add_metadata sequentially (-22%) - add_tags(): use set-based dedup instead of O(n) list scans per tag, early return when tags list is empty (-70% on duplicate tags) - handle_event/ahandle_event: early return when handlers list is empty - _configure(): skip throwaway CallbackManager construction on the common path where inheritable_callbacks is provided These are the top bottlenecks identified by profiling langgraph's react_agent benchmark, where langchain_core callbacks account for ~35% of runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Parents
Loading