Skip to main content

Message Queue

PraisonAI CLI’s Interactive Mode supports message queuing, allowing you to type new prompts while the AI agent is still processing a previous task. Messages are queued and executed sequentially as each task completes. This feature is inspired by Claude Code, Windsurf Cascade, Cursor, and Gemini CLI.

Overview

Message Queue Demo Message Queue for Async Tasks The message queue system provides:
  • Non-blocking input - Type new messages while agent is processing
  • FIFO processing - Messages are processed in order (First In, First Out)
  • Visual indicators - See queue status and pending messages
  • Queue management - View, clear, or remove queued messages
  • Thread-safe - Safe concurrent access from multiple threads

Quick Start

How It Works

  1. User types a message - If agent is idle, it processes immediately
  2. Agent is busy - Message is added to the queue
  3. Agent completes - Next message in queue is automatically processed
  4. Queue is empty - Agent returns to idle state

Queue Commands

Viewing the Queue

Clearing the Queue

Removing a Specific Message

Live Status Display

While the agent is processing, a live status panel shows real-time updates:
The status updates as the agent progresses:
  • ā³ Thinking... - Initial processing
  • ā³ Creating agent... - Setting up the agent
  • ā³ Calling LLM... - Making the API call

Visual Indicators

The queue system provides visual feedback:

Processing States

The agent can be in one of three states:

Example Workflow

Programmatic Usage

You can also use the message queue programmatically:

Using the Handler

Visual Display

API Reference

MessageQueue

StateManager

QueueDisplay

MessageQueueHandler

Thread Safety

The message queue is thread-safe and uses threading.Lock for all operations. This ensures safe concurrent access when:
  • User input thread adds messages
  • Processing thread pops messages
  • Display thread reads queue status

Performance

The message queue is designed for minimal performance impact:
  • Lazy loading - Module only loaded when interactive mode starts
  • Simple data structure - Python list with O(1) append, O(n) pop(0)
  • No external dependencies - Uses only Python standard library
  • Minimal memory - Stores only message strings

Comparison with Other Tools

Async Processing Classes

The message queue includes additional classes for async processing:

AsyncProcessor

Runs work functions in background threads:

LiveStatusDisplay

Tracks and displays real-time status:

NonBlockingInput

Manages async user input:

Interactive TUI

Full interactive terminal interface

Slash Commands

All available slash commands

Cost Tracking

Monitor token usage and costs

Session Management

Save and restore sessions