Skip to main content
Important: AutoTurn automatically disables streaming mode. When AutoTurn is enabled, the SDK uses non-streaming responses to properly handle response splitting and turn management. Choose either streaming OR conversational turns based on your use case.

Key Benefits

  • Natural Message Flow: AI can send multiple messages in a row, just like humans do
  • Intelligent Splitting: Automatically breaks long responses into digestible conversation turns
  • Realistic Timing: Simulates human typing speeds with natural variation
  • Follow-up Detection: Identifies when responses might prompt user engagement
  • Event-Driven: Comprehensive events for real-time UI updates

Basic Usage

Simple Enable

Enable AutoTurn with default settings:

Advanced Configuration

Fine-tune AutoTurn behavior with custom settings:

Configuration Options

How AutoTurn Works

Priority-Based Processing

The system follows a clear priority order for response splitting:
  1. Priority 1: If autoTurn is enabled AND content has newlines → ALWAYS split on newlines
  2. Priority 2: If no newlines but pre-split turns are available → Apply splitProbability to decide
  3. Priority 3: Otherwise → Process normally without splitting

Intelligent Turn Management

Realistic Timing Calculation

Realistic delays are calculated based on content length and typing speed:

Event System

Unified Message Events

All message types (regular, auto-turn, follow-up) use the same event system:

Message Types

  • regular: Standard user-initiated messages and responses
  • auto: Messages from conversational turns (split responses)
  • followup: Automatic follow-up requests when AI indicates more content

Follow-Up Request Management

AutoTurn includes intelligent follow-up handling to prevent infinite loops:

Follow-Up Protection

  • Sequential Limiting: Prevents infinite follow-up loops
  • Image Generation Protection: Blocks follow-ups immediately after image generation
  • User Reset: All counters reset when user sends new message

Message Cancellation

Message cancellation is automatically handled when users send new messages:

Cancellation Events

Integration with Other Features

Image Generation

AutoTurn coordinates with automatic image generation:

Chat History

AutoTurn messages are automatically added to chat history with proper metadata:

Best Practices

Configuration Guidelines

UI Implementation

Troubleshooting

Common Issues

AutoTurn Not Working
Messages Not Splitting
Delays Too Long/Short

Next Steps

Tool Calling

Combine conversational turns with function calling

Image Generation

Automatic image generation with natural conversation flow

Event System

Master the comprehensive event system

Streaming Responses

Compare with streaming for different use cases