Skip to content

[BUG]: langchain integration marks GraphInterrupt as an error (should be control flow, as fixed in dd-trace-py) #9846

Description

@RodrigoMural

Tracer Version(s)

5.82.0

Node.js Version(s)

22.21.0

Bug Report

ToolInvokePlugin in datadog-plugin-langchain marks a span as errored when the tool throws a LangGraph GraphInterrupt. That exception is not a failure, it is how LangGraph suspends for human-in-the-loop: interrupt() throws, and the graph catches it upstream to persist the checkpoint and pause.

The result is that every client-side/human-in-the-loop tool call appears as an error in APM and LLM Observability, while the application behaves correctly. On a working agent, the trace says the tool failed.

This is the same bug that was reported and fixed on the Python side in DataDog/dd-trace-py#16614 (fixed by PR #16983). There, the integration already exempted ParentCommand from error marking and GraphInterrupt fell through; the fix extended the check.

Reproduce

  1. Build a LangGraph agent (createAgent) with a tool whose implementation calls interrupt(...) from @langchain/langgraph.
  2. Run a turn where the model calls that tool.
  3. The tool span is marked as an error with GraphInterrupt, even though the run suspends and resumes normally.

Expected
A GraphInterrupt should close the span without error, as ParentCommand already does.

Suggested fix
@langchain/langgraph exports isGraphBubbleUp, the guard for the base class of GraphInterrupt, ParentCommand and GraphDrained — all of which are graph control flow rather than failures. Guarding on the base class avoids the recurrence that happened in Python, where enumerating the subclasses left one behind.

Note: dd-trace-js has no dedicated langgraph integration (unlike Python), so LangGraph users are traced through the langchain one and hit this by default.

Reproduction Code

No response

Error Logs

No response

Tracer Config

No response

Operating System

No response

Bundling

No Bundling

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions