🐛 Bug Report: LangChain: TraceloopCallbackHandler raises AttributeError at every LangGraph interrupt() and resume

Đang mở
#4,636 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lakshya-dhariwal đang làm issue này rồi.

Từ ngày 18/10/2026.

  • #4638 của @lakshya-dhariwal — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
observability

Hướng nghiên cứu

Start by reading the LangChain instrumentation’s TraceloopCallbackHandler and the BaseCallbackManager wrapper described in the issue. Reproduce the interrupt and resume callbacks using the provided LangGraph example, then inspect the existing instrumentation tests for callback coverage. Done means the reproduction logs no callback errors and both graph events are represented in the trace; pull request #4638 is already open against this issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Which component is this bug for?

Langchain Instrumentation

📜 Description

With the LangChain instrumentation active, every LangGraph interrupt() and every Command(resume=...) makes LangChain log Error in TraceloopCallbackHandler.on_interrupt callback: AttributeError(...), and the same for on_resume. The BaseCallbackManager.__init__ wrapper adds the handler to every callback manager, including LangGraph's graph callback manager, which calls on_interrupt / on_resume on its handlers, and TraceloopCallbackHandler does not implement them. The run itself works, but each pause and resume produces an error in the logs and is missing from the trace.

👟 Reproduction steps
# LangGraph: at every interrupt() and every resume, LangChain logs an exception raised by TraceloopCallbackHandler
# (on_interrupt / on_resume).
import json, logging, sys
from importlib.metadata import version
from typing import Annotated
from typing_extensions import TypedDict
try:
    import httpx2 as httpx                         # openai >= 3
except ImportError:
    import httpx
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
LangchainInstrumentor().instrument(tracer_provider=TracerProvider())

from langchain_core.messages import HumanMessage
from langchain_openai import ChatOpenAI
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, START, StateGraph
from langgraph.graph.message import add_messages
from langgraph.types import Command, interrupt

class Errors(logging.Handler):                     # LangChain logs a callback's exception as "Error in X callback: ..."
    seen = []
    def emit(self, record):
        if record.getMessage().startswith("Error in "):
            Errors.seen.append(record.getMessage()[:160])
logging.getLogger("langchain_core.callbacks.manager").addHandler(Errors())

def reply(request):                                # a local stand-in for the OpenAI API
    return httpx.Response(200, json={"id": "c-1", "object": "chat.completion", "created": 0, "model": "gpt-4o-mini",
        "choices": [{"index": 0, "message": {"role": "assistant", "content": "Paris."}, "finish_reason": "stop"}],
        "usage": {"prompt_tokens": 3, "completion_tokens": 1, "total_tokens": 4}})
llm = ChatOpenAI(model="gpt-4o-mini", api_key="x", base_url="http://mock/v1", max_retries=0,
                 http_client=httpx.Client(transport=httpx.MockTransport(reply)))

class State(TypedDict):
    messages: Annotated[list, add_messages]

def agent(state):
    return {"messages": [llm.invoke(state["messages"])]}
def approve(state):                                # human in the loop: pause until the app resumes the run
    return {"messages": [HumanMessage(f"approved: {interrupt('approve?')}")]}

g = StateGraph(State)
g.add_node("agent", agent); g.add_node("approve", approve)
g.add_edge(START, "agent"); g.add_edge("agent", "approve"); g.add_edge("approve", END)
graph = g.compile(checkpointer=InMemorySaver())

print(f"opentelemetry-instrumentation-langchain {version('opentelemetry-instrumentation-langchain')} | "
      f"langgraph {version('langgraph')} | langchain-core {version('langchain-core')} | python {sys.version.split()[0]}")
config = {"configurable": {"thread_id": "t1"}}
out = graph.invoke({"messages": [("user", "Capital of France?")]}, config)
print("paused at interrupt:", "__interrupt__" in out)
out = graph.invoke(Command(resume="yes"), config)
print("after resume:", out["messages"][-1].content)
print("errors LangChain logged:")
for e in Errors.seen:
    print("  ", e)
👍 Expected behavior

No errors at the interrupt and the resume; the handler either handles these graph events or is not added to the graph callback manager.

👎 Actual Behavior with Screenshots
opentelemetry-instrumentation-langchain 0.62.4 | langgraph 1.2.16 | langchain-core 1.6.12 | python 3.13.7
paused at interrupt: True
after resume: approved: yes
errors LangChain logged:
   Error in TraceloopCallbackHandler.on_interrupt callback: AttributeError("'TraceloopCallbackHandler' object has no attribute 'on_interrupt'")
   Error in TraceloopCallbackHandler.on_resume callback: AttributeError("'TraceloopCallbackHandler' object has no attribute 'on_resume'")
🤖 Python Version

3.13 (also seen with 3.12)

📃 Provide any additional context for the Bug.

opentelemetry-instrumentation-langchain 0.62.4 (the latest release; main has no changes to this package since), langgraph 1.2.16, langchain-core 1.6.12, langchain-openai 1.7.2 (also langgraph 1.2.14 / langchain-core 1.6.9).

👀 Have you spent some time to check if this bug has been raised before?
  • I checked and didn't find similar issue
Are you willing to submit PR?

None

Ngôn ngữ chính
Python
Star
7.5k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của traceloop/openllmetry

Tất cả issue của traceloop/openllmetry

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.