Skip to content

instrumentLangGraph input/output recording only works with MessagesAnnotation #19628

Closed

Description

@priscilawebdev

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

^10.40.0

Framework Version

No response

Link to Sentry event

https://pri-dogfooding-ai.sentry.io/insights/ai-agents/?project=4510951776059472&statsPeriod=30d&trace=5eb7a6719e6a45dd8b4accab1881c7bd&span=a2fd3ab2120a6698&trace-timestamp=1772622965

Reproduction Example/SDK Setup

No response

Steps to Reproduce

const CustomState = Annotation.Root({
  idea: Annotation(),
  expanded: Annotation(),
  validated: Annotation(),
});

const graph = new StateGraph(CustomState)
  .addNode("expand", expandNode)
  .addEdge(START, "expand")
  .addEdge("expand", END);

Sentry.instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });
const compiled = graph.compile({ name: "my_agent" });
const result = await compiled.invoke({ idea: "test idea" });

Expected Result

The invoke_agent span should contain the graph's input ({ idea: "test idea" }) and output state as span attributes.

Actual Result

The invoke_agent span has no input or output data. No error or warning is logged.

Additional Context

instrumentCompiledGraphInvoke hardcodes extraction for MessagesAnnotation:

const inputMessages = args.length > 0 ? ((args[0])?.messages ?? []) : [];

It looks for args[0].messages, which only exists when using MessagesAnnotation. Custom state keys (like idea, expanded, etc.) are ignored. The OTEL gen_ai.input.messages / gen_ai.output.messages attributes are message-array-oriented by design, but there is no fallback to record arbitrary state.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Activity

  1. linear commented on Mar 4, 2026

    @linear
  2. self-assigned this
    on Mar 4, 2026
  3. andreiborza commented on Mar 4, 2026

    @andreiborza
    Member

    Thanks for filing this @priscilawebdev, this current behavior matches the python SDK's LangGraph integration. I'll have a go at serializing the entire state here and talk to the python team about getting that in there too if we agree on the approach.

  4. removed their assignment
    on Apr 10, 2026
  5. added a commit that references this issue on Oct 7, 2026
    f8abf00
  6. github-actions commented on Oct 8, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #23315, which was included in the 11.6.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions