Reasoning Proposal
Summary
Problem Statement
LLMs increasingly use chain-of-thought reasoning to improve response quality, but there’s no standardized way to surface reasoning signals while maintaining privacy and state continuity across turns.Motivation
AG-UI should support LLM reasoning without breaking existing apps.- Reasoning visibility & continuity: We must surface reasoning signals
(e.g., reasoning summaries) and support encrypted reasoning items for
state carry-over across turns—especially under
store:false
/ZDR—without exposing raw chain-of-thought. - Backwards compatibility: Existing AG-UI clients must keep working unchanged. New capabilities should be non-breaking.
Status
- Status: Draft
- Author(s): Markus Ecker (mail@mme.xyz)
Detailed Specification
Overview
This proposal introduces:- New events for reasoning lifecycle management
- A new
ReasoningMessage
type for message history - Support for encrypted reasoning content
New Reasoning Events
These events represent the lifecycle of reasoning messages in a conversation.ReasoningStartEvent
Marks the start of reasoning.Property | Type | Description |
---|---|---|
messageId | string | Unique identifier of this reasoning |
encryptedContent | string? | Optionally the encrypted content |
ReasoningMessageStartEvent
Signals the start of a reasoning message.Property | Type | Description |
---|---|---|
messageId | string | Unique identifier of the message |
role | "assistant" | Role of the reasoning message |
ReasoningMessageContentEvent
Represents a chunk of content in a streaming reasoning message.Property | Type | Description |
---|---|---|
messageId | string | Matches the ID from ReasoningMessageStartEvent |
delta | string | Reasoning content chunk (non-empty) |
ReasoningMessageEndEvent
Signals the end of a reasoning message.Property | Type | Description |
---|---|---|
messageId | string | Matches the ID from ReasoningMessageStartEvent |
ReasoningMessageChunkEvent
A convenience event to auto start/close reasoning messages.Property | Type | Description |
---|---|---|
messageId | string? | Message ID (first event must be non-empty) |
delta | string? | Reasoning content chunk |
ReasoningEndEvent
Marks the end of reasoning.Property | Type | Description |
---|---|---|
messageId | string | Unique identifier of this reasoning |
New ReasoningMessage Type
Removed Events
These events have never been publicly documented and will be removed:THINKING_TEXT_MESSAGE_START
THINKING_TEXT_MESSAGE_CONTENT
THINKING_TEXT_MESSAGE_END
Implementation Considerations
Client SDK Changes
TypeScript SDK:- New event types in
@ag-ui/core
- ReasoningMessage type in message unions
- Reasoning event handlers in subscriber
- Support for encrypted content handling
- New event classes in
ag_ui.core.events
- ReasoningMessage class
- Encryption/decryption utilities
Privacy and Security
- Encrypted reasoning: Support for encrypted reasoning content that clients cannot decrypt
- State continuity: Encrypted reasoning items can be passed across turns without exposing content
- ZDR compliance: Works with
store:false
and zero data retention policies
Backward Compatibility
- Clients not handling reasoning events continue to work
- Reasoning messages are optional in message history
- No changes required to existing integrations
Use Cases
Chain-of-Thought Visibility
Show users that the model is “thinking” without exposing internal reasoning.Reasoning Summaries
Provide high-level summaries of reasoning process for transparency.State Continuity
Maintain reasoning context across conversation turns without storing raw content.Compliance and Privacy
Meet data retention requirements while preserving reasoning capabilities.Examples
Basic Reasoning Flow
Convenience Event Usage
Testing Strategy
- Unit tests for new event types
- Integration tests with reasoning-capable models
- Backward compatibility tests with existing clients
- Encryption/decryption roundtrip tests
- Performance tests for reasoning event streaming