🐛 Bug Report: LangChain: TraceloopCallbackHandler raises AttributeError at every LangGraph interrupt() and resume
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của traceloop/openllmetry
-
🐛 Bug Report: OpenAI Responses: with_raw_response.create() raises when the body can't be parsed, though the uninstrumented call returnsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
traceloop/openllmetry#4717 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentationCó thể đã có người làm @Quantum-Enigma-dot đã nhận 21 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
traceloop/openllmetry#4665 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 Bug Report: OpenAI instrumentation drops gen_ai.usage.reasoning_tokens on streamed chat completionsCó thể đã có người làm @jayfeng7 đã nhận 23 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
traceloop/openllmetry#4660 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Report: Failed dataset deletes still remove local rows and columnsCó thể đã có người làm @inchang-ing đã nhận 32 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
traceloop/openllmetry#4630 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penaltyCó thể đã có người làm @shantam77 đã nhận 38 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
traceloop/openllmetry#4598 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của traceloop/openllmetry
Issue tương tự
-
CI flake: test-windows times out spawning Node in tests/test_antigravity_node_hooks.py (develop red)Đang mởarea/ci P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
benchmark
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
mozilla-ai/cq#601 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bump Python to 3.14 or 3.15Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày