ag-ui-protocol / ag-ui-protocol/ag-ui

[Feature]: Add opt-in support for reasoning messages in Claude adapter snapshots

未关闭
#2,421 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
Python
星标
15.9k
派生
1.4k
平均合并
1 天 17 小时
30 天内合并 PR
163

描述

### Pre-flight Checklist

- [x] I have searched existing issues and this hasn't been requested yet.

### Problem or Motivation

The Claude Agent SDK integration emits reasoning events during streaming, but the final `MESSAGES_SNAPSHOT` does not retain those reasoning messages. As a result, the client transcript after a run can differ from what was visible during streaming, making reasoning unavailable for UI history and replay.

Some applications need to retain reasoning, while others should avoid persisting it for privacy, retention, payload-size, or provider-specific data reasons.

### Proposed Solution

Add an adapter configuration option to opt in to reasoning messages in `MESSAGES_SNAPSHOT`.

Expected behavior:

• Disabled by default for backward compatibility.
• When enabled, include ordered  role: `reasoning` messages in snapshots.
• Preserve encrypted reasoning values when available.
• Avoid duplicating reasoning messages already present in a snapshot.
• Keep replay-only reasoning out of provider input.
• Emit the final snapshot before `RUN_FINISHED` or  `RUN_ERROR`.

### Alternatives Considered

1. Always include reasoning in snapshots. This could unexpectedly increase persisted data and expose content that applications do not want to retain.
2. Continue exposing reasoning only through live events. This does not support reliable history or replay.
3. Let each application implement custom snapshot enrichment. This duplicates adapter logic and can produce inconsistent behavior.

### Additional Context

The protocol already supports messages with  role: `reasoning`. The requested change concerns the Claude Agent SDK integration and should preserve its current default behavior while allowing applications to explicitly choose durable reasoning history.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。