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

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

Aperta
#2,421 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
15.9k
Fork
1.4k
Merge medio
1g 17h
PR unite (30g)
163

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.