Skip to content

Langsmith 流式 Graph 输入记录为空数组的问题 #615

@white-loub

Description

@white-loub

Describe the bug

当使用 Langsmith 监控 Eino Graph 并通过流式方式 (graph.Stream()) 执行时,Langsmith Trace 详情页中 Graph 节点的 Input 字段显示为空数组 stream input[],无法正确记录实际的用户输入内容。而 Graph 内部的 Lambda 节点(非流式节点)以及 ChatModel 节点(流式节点)的输入输出均能正常显示。

To Reproduce

Steps to reproduce the behavior:

  1. 配置 callbacks/langsmith 作为 Graph 的回调处理器。
  2. 创建一个 Eino Graph(例如 compose.NewGraph[string, *schema.Message]())。
  3. 使用流式方式调用 Graph:streamReader, err := graph.Stream(ctx, userInput, opts...)。
  4. 打开 Langsmith 控制台查看对应的 Trace。
  5. 点击 Graph 节点,查看 Input 标签页。
  6. 现象:显示 stream input[](空数组),而非实际的 userInput 字符串。

Expected behavior

Langsmith 应正确显示 Graph 的输入内容(例如用户输入的字符串 "你好"),而不是空数组。

Version:

github.com/cloudwego/eino-ext/callbacks/langsmith (latest)

Environment:

GOVERSION='go1.25.3'

Additional context

我尝试在本地修复。修复方案是在 OnStartWithStreamInput 方法中区分组件类型:对于components.ComponentOfChatModel,继续使用 extractModelInput 提取 messages 和 config;对于其他组件(Graph/Lambda/Tool),直接使用原始输入,与 OnStart 方法保持一致。修复后,Graph 的输入能够正确显示实际内容。

除了输入记录为空数组的问题外,输出似乎也存在类似问题(未验证)。当 Graph 的输出类型为 string(例如 compose.NewGraph[string, string])时,OnEndWithStreamOutput 中使用的 extractModelOutput 可能同样无法正确提取 string 类型的输出数据。

因此,该问题可能同时影响流式 Graph 及非 ChatModel 的流式节点的输入和输出记录。

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugThis is a bug-report. Bug-fix PRs use `C-enhancement` instead.E-help-wantedStuff where we want help.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions