Quick Start
Test with Long Task
Send a long-running request like “research solar energy trends” to your bot, then immediately send another message. You’ll get instant feedback instead of silence.
How It Works
Choosing a Busy Mode
| Mode | When to Use | Behavior |
|---|---|---|
queue | Research bots, task completion important | Messages queued, processed in order after current task |
interrupt | Interactive chat, latest intent matters | Cancels current task, starts new one immediately |
steer | Real-time collaboration (experimental) | Injects messages into running task (fallback to queue) |
Configuration Options
Configure run control throughBotConfig or directly with bot constructors:
| Option | Type | Default | Description |
|---|---|---|---|
busy_mode | str | "queue" | Policy for mid-run messages. One of "queue", "interrupt", "steer". |
busy_ack | str | "⏳ {action} — will be considered next" | Template for busy acknowledgment. {action} is replaced with "noted" (queued) or "added to pending request" (merged). |
BotConfig API Reference
Full configuration options for bot settings
Common Patterns
Long Research Bot (Queue Mode)
Interactive Chat Bot (Interrupt Mode)
Using /stop Mid-Task
When a bot is processing a long request:Best Practices
When to Use Queue vs Interrupt vs Steer
When to Use Queue vs Interrupt vs Steer
Use queue mode for bots that do important work users shouldn’t lose — research bots, analysis tools, content generators. Users get acknowledgments but work continues.Use interrupt mode for conversational bots where the latest message reflects user intent — chat assistants, Q&A bots, real-time helpers.Use steer mode (experimental) for collaborative scenarios where users provide guidance during long tasks. Currently falls back to queue mode.
Why /stop Requires Run Control
Why /stop Requires Run Control
The
/stop command works through the SessionRunControl system. Without run control enabled, bots process messages sequentially with traditional locking, so /stop would queue behind the current task instead of interrupting it.Enable run control by setting busy_mode to any value other than the default.Race Protection via run_generation
Race Protection via run_generation
Each run gets a unique generation number. When a run finishes, it only clears the session state if its generation matches the current one. This prevents cancelled runs from overwriting fresh state when they complete.
Cleaning Up Stale Sessions
Cleaning Up Stale Sessions
Use
SessionRunControl.cleanup_stale_sessions(max_age_seconds=3600) to clean up old sessions. This prevents memory leaks in long-running bots and removes abandoned user sessions.Related
Bot Commands
Built-in chat commands including /stop
Messaging Bots
Complete guide to Telegram, Discord, Slack bots

