Bug Report: Compatibility issue with langgraph 1.1.7 — TypeError when injecting TraceloopCallbackHandler
Which component is this bug for?
Langchain Instrumentation
📜 Description
Heads up — langgraph 1.1.7 (just released) introduced new _GraphCallbackManager and _AsyncGraphCallbackManager classes that override add_handler() with strict type checking. This causes a TypeError when opentelemetry-instrumentation-langchain's _BaseCallbackManagerInitWrapper injects the TraceloopCallbackHandler, since it inherits from BaseCallbackHandler rather than langgraph's new GraphCallbackHandler.
We've also filed an issue on langgraph about the strictness of their type check (https://github.com/langchain-ai/langgraph/issues/7543), but wanted to flag this here too in case you'd like to add a defensive check on this side as well.
👟 Reproduction steps
- Install
langgraph>=1.1.7andopentelemetry-instrumentation-langchain>=0.59.0 - Instrument with
LangchainInstrumentor().instrument() - Create a LangGraph agent with
create_react_agent() - Invoke the graph — crashes with
TypeError: handlers must inherit GraphCallbackHandler
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
LangchainInstrumentor().instrument()
from langchain_core.messages import HumanMessage
from langgraph.prebuilt import create_react_agent
from langchain.tools import tool
@tool
def add_numbers(a: int, b: int) -> int:
"""Return the sum of two numbers"""
return a + b
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(model="claude-sonnet-4-5-20250929", api_key="test")
graph = create_react_agent(llm, tools=[add_numbers])
import asyncio
asyncio.run(graph.ainvoke({"messages": [HumanMessage(content="Say hello")]}))
👍 Expected behavior
The instrumentation should gracefully handle callback managers that restrict handler types, either by checking the manager type before injecting or by catching the TypeError.
👎 Actual Behavior with Screenshots
Crashes with:
File "opentelemetry/instrumentation/langchain/__init__.py", line 383, in __call__
instance.add_handler(self._callback_handler, True)
File "langgraph/callbacks.py", line 330, in add_handler
raise TypeError("handlers must inherit GraphCallbackHandler")
TypeError: handlers must inherit GraphCallbackHandler
The root cause is in _BaseCallbackManagerInitWrapper.__call__ (line 383) — it calls instance.add_handler() for every BaseCallbackManager subclass, including langgraph's new graph-specific managers that reject non-GraphCallbackHandler handlers.
Possible fixes — a couple of ideas, you all know this codebase far better so take these with a grain of salt:
Option 1: Check the manager type before injecting:
def __call__(self, wrapped, instance, args, kwargs):
wrapped(*args, **kwargs)
try:
from langgraph.callbacks import _GraphCallbackManager, _AsyncGraphCallbackManager
if isinstance(instance, (_GraphCallbackManager, _AsyncGraphCallbackManager)):
return
except ImportError:
pass
for handler in instance.inheritable_handlers:
if isinstance(handler, type(self._callback_handler)):
break
else:
self._callback_handler._callback_manager = instance
instance.add_handler(self._callback_handler, True)
Option 2: Defensively catch the TypeError:
try:
instance.add_handler(self._callback_handler, True)
except TypeError:
pass
🤖 Python Version
3.14.0
📃 Provide any additional context for the Bug.
Versions:
- opentelemetry-instrumentation-langchain==0.59.2
- langgraph==1.1.7 (broken), 1.1.6 (works)
- langchain-core==1.3.0
- opentelemetry-instrumentation==0.61b0
👀 Have you spent some time to check if this bug has been raised before?
- [x] I checked and didn't find similar issue
Fixed: https://github.com/langchain-ai/langgraph/pull/7544