🐛 Bug Report: LangChain: TraceloopCallbackHandler raises AttributeError at every LangGraph interrupt() and resume
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
traceloop/openllmetry のほかの issue
-
🐛 Bug Report: OpenAI Responses: with_raw_response.create() raises when the body can't be parsed, though the uninstrumented call returns対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug python
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
traceloop/openllmetry#4717 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentation対応中かも @Quantum-Enigma-dot が 21 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
traceloop/openllmetry#4665 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug Report: OpenAI instrumentation drops gen_ai.usage.reasoning_tokens on streamed chat completions対応中かも @jayfeng7 が 23 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
traceloop/openllmetry#4660 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bug Report: Failed dataset deletes still remove local rows and columns対応中かも @inchang-ing が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
traceloop/openllmetry#4630 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penalty対応中かも @shantam77 が 38 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
traceloop/openllmetry#4598 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
traceloop/openllmetry の issue をすべて見る
似ている issue
-
CI flake: test-windows times out spawning Node in tests/test_antigravity_node_hooks.py (develop red)オープンarea/ci P2
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
benchmark
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
mozilla-ai/cq#601 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信