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

オープン
#4,636 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lakshya-dhariwal がすでに取り組んでいます。

2026年10月18日 から。

  • #4638 @lakshya-dhariwal による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
observability

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Python
スター
7.5k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

traceloop/openllmetry のほかの issue

traceloop/openllmetry の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。