Skip to content

[bot] LangGraph Platform API client (@langchain/langgraph-sdk) not instrumented — no tracing for cloud agent execution #2199

Description

@braintrust-bot

Summary

@langchain/langgraph-sdk is a dedicated HTTP client SDK for the LangGraph Platform (LangGraph Cloud / hosted agent service). It is a completely separate npm package from the @langchain/langgraph local framework and from @langchain/core. As of v1.9.25 it is actively maintained with its own release cadence.

This package is not instrumented today. The existing langchain.ts config only hooks into @langchain/core's CallbackManager (the local framework callback system). Calls made through @langchain/langgraph-sdk bypass that system entirely.

Gap Details

Package: @langchain/langgraph-sdk
Current latest: v1.9.25
Source: https://github.com/langchain-ai/langgraphjs/tree/main/libs/sdk
Zero matches for langgraph-sdk anywhere in js/src/ (confirmed via grep).

Key execution surfaces

Method Description
client.runs.create(threadId, assistantId, options) Start a background run on a thread
client.runs.stream(threadId, assistantId, options) Stream a run's output (returns AsyncGenerator)
client.threads.stream(threadId, options) Stream from a thread checkpoint
client.runs.wait(threadId, runId) Wait for a run to complete and return final output

These are the primary generative-AI execution calls that users make against a deployed LangGraph Platform agent. None are traced.

Why the existing instrumentation does not cover this

The langchain.ts config targets:

// js/src/auto-instrumentations/configs/langchain.ts
module: { name: "@langchain/core", filePath: "dist/callbacks/manager.js" }
functionQuery: { className: "CallbackManager", methodName: "configure" }

@langchain/langgraph-sdk makes direct HTTP requests (via its own BaseClient) to the LangGraph Platform REST API. It does not instantiate @langchain/core models or invoke CallbackManager. The two packages share only a namespace prefix, not a runtime dependency path.

Braintrust Docs Status

The Braintrust LangGraph integration page covers only the local framework (@langchain/langgraph + @langchain/core callbacks). There is no mention of @langchain/langgraph-sdk or LangGraph Platform/Cloud. Users running agents on LangGraph Platform through the SDK will see no spans in Braintrust today.

Suggested Approach

Instrument BaseClient or the specific streaming/run methods in @langchain/langgraph-sdk:

  • Entry file to target: dist/root.cjs or dist/index.cjs (CommonJS) / dist/root.js (ESM) — the file where Client, RunsClient, and ThreadsClient are defined
  • Methods: RunsClient.stream, RunsClient.create, RunsClient.wait, ThreadsClient.stream
  • Channel pattern: consistent with existing naming, e.g. orchestrion:@langchain/langgraph-sdk:runs.stream

Alternatively, a source-replacement patch (similar to the Mastra approach) could wrap the Client constructor to inject tracing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions