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
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
- User types a message - If agent is idle, it processes immediately
- Agent is busy - Message is added to the queue
- Agent completes - Next message in queue is automatically processed
- Queue is empty - Agent returns to idle state
Queue Commands
| Command | Description |
|---|---|
/queue | Show all queued messages |
/queue clear | Clear the entire queue |
/queue remove N | Remove message at index N |
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:ā³ Thinking...- Initial processingā³ Creating agent...- Setting up the agentā³ Calling LLM...- Making the API call
Visual Indicators
The queue system provides visual feedback:| Indicator | Meaning |
|---|---|
ā³ Processing... | Agent is currently processing a task |
š Queued (N) | N messages are waiting in the queue |
ā³ message | A queued message (with truncation for long messages) |
š§ tool_name | Tool being executed |
š» command | Shell command being run |
Processing States
The agent can be in one of three states:| State | Description |
|---|---|
IDLE | Ready to process new messages immediately |
PROCESSING | Currently working on a task |
WAITING_APPROVAL | Waiting for user approval (e.g., file write) |
Example Workflow
Programmatic Usage
You can also use the message queue programmatically:Using the Handler
Visual Display
API Reference
MessageQueue
| Method | Description |
|---|---|
add(message) | Add message to queue (returns False if empty) |
pop() | Remove and return first message (FIFO) |
peek() | View first message without removing |
clear() | Remove all messages |
get_all() | Get all messages as list |
remove_at(index) | Remove message at specific index |
is_empty | Property: True if queue is empty |
count | Property: Number of messages in queue |
StateManager
| Method/Property | Description |
|---|---|
current_state | Get current ProcessingState |
is_idle | True if state is IDLE |
is_processing | True if state is PROCESSING |
set_state(state) | Set new state (triggers callback) |
QueueDisplay
| Method | Description |
|---|---|
format_queue() | Format queued messages with ā³ prefix |
format_status() | Format processing status indicator |
format_queue_count() | Format queue count indicator |
MessageQueueHandler
| Method | Description |
|---|---|
submit(message) | Submit message (process or queue) |
on_processing_complete() | Called when processing finishes |
get_status() | Get queue count, state, messages |
clear_queue() | Clear all queued messages |
Thread Safety
The message queue is thread-safe and usesthreading.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
| Feature | PraisonAI | Claude Code | Windsurf | Cursor |
|---|---|---|---|---|
| Queue messages | ā | ā | ā | ā |
| View queue | ā
/queue | ā | ā | ā |
| Clear queue | ā
/queue clear | ā | ā Delete | ā |
| Remove specific | ā
/queue remove N | ā | ā Delete | ā |
| Visual indicators | ā | ā | ā | ā |
| FIFO processing | ā | ā | ā | ā |

