@0xsero/opencode-queue
v0.1.0
Published
Message queue plugin for OpenCode - control message flow with hold/immediate modes
Maintainers
Readme
OpenCode Message Queue Plugin
Control how messages behave while a session is running. Queue them up or send them immediately.
NOTE
Be aware that when a message is sent while model is running it looks like it's sent, then when the model is really done it gets sent again.
I can't fix that yet, but the functionality does work the model won't see the 2nd message until after it's done
Modes
| Mode | Behavior |
|------|----------|
| immediate | Messages are sent right away (default) |
| hold | Messages are queued until the current run finishes, then sent in order |
Installation
cd .opencode
bun add @0xsero/open-queueThen add to your .opencode/opencode.jsonc:
{
"plugin": ["@0xsero/open-queue"]
}Optionally, copy the slash command to your project:
cp node_modules/@0xsero/open-queue/command/queue.md .opencode/command/Usage
Slash Command
The easiest way to control the queue is with the /queue command:
/queue status # Check current mode and queue size
/queue hold # Start queueing messages
/queue immediate # Send messages immediately (drains any queued)Environment Variable
Set the initial mode via environment variable:
# Start in hold mode
OPENCODE_MESSAGE_QUEUE_MODE=hold opencode
# Start in immediate mode (default)
OPENCODE_MESSAGE_QUEUE_MODE=immediate opencodeProgrammatic (via LLM)
The plugin exposes a queue tool that the LLM can invoke directly:
- "Set queue mode to hold"
- "Check queue status"
- "Switch to immediate mode"
How It Works
Hold Mode
When in hold mode:
- Incoming messages are intercepted by the
chat.messagehook - Message parts are converted and stored in a per-session queue
- Text parts are marked as
ignoredto hide them from the current run - When the session becomes idle (
session.statusorsession.idleevents), queued messages are drained in order viaclient.session.prompt()
Immediate Mode
When in immediate mode:
- Messages pass through without modification
- Any existing queued messages are drained when switching from hold to immediate
API
Tool: queue
| Action | Description |
|--------|-------------|
| status | Returns current mode, queue size, and session busy state |
| hold | Sets mode to hold (queue messages) |
| immediate | Sets mode to immediate and drains any queued messages |
Events Handled
session.status- Tracks busy/idle state, drains queue when idlesession.idle- Alternative idle detection, drains queue
Hooks Used
chat.message- Intercepts messages in hold mode, queues them, marks text as ignored
Limitations
- Best-effort queueing: OpenCode does not yet allow plugins to fully defer message creation. The plugin hides text content but non-text attachments may still be sent.
- Global mode: The mode is global across all sessions. Per-session mode could be added if needed.
- Plugin scope: Queued messages are lost if OpenCode restarts.
Links
License
MIT
