This document specifies the architecture for the Tier 3 Bidirectional Discord-OMP Integration. This system connects the Oh My Pi (OMP) local agent workspace with a persistent Discord bot, allowing developers to monitor agent task queues, receive tool-call alerts, and inject steering commands remotely.
Description: Command execution started in /home/dev
Fields:
Input: bash\nrm -rf ./*\n
Session: session-xyz-123
Footer: OMP Agent System | Timestamp
6.2. Turn End Summary Embed
Color: Green (#00FF00)
Title: โ Turn Completed
Description: Agent has finished processing the current prompt.
Fields:
Tokens Used: 1245
Pending Messages: False
Footer: OMP Agent System | Timestamp
7. Failure Modes & Observability
API Unreachable: Extension catches ECONNREFUSED on webhook POST. It implements a circuit breaker, logs to pi.logger.error(), and continues execution without blocking the agent.
Discord Rate Limiting: discord.py handles HTTP 429 transparently. If queues fill, events are dropped (fire-and-forget) to prevent memory leaks in the FastAPI backend.
Lost Steering Commands: Steer commands remain pending in SQLite. If OMP crashes, old commands may be injected upon restart. Extension should purge stale commands (older than 1 hour) on startup.
Observability: FastAPI uses standard logging. SQLite tracks all dispatched commands for auditing.
8. Decision Records
Why Polling over WebSocket?
While SSE/WS is lower latency, REST polling every 5 seconds is simpler to deploy and completely stateless. Polling avoids managing persistent connection lifecycles within the OMP Extension API.
Why Python/FastAPI for Backend?discord.py is the most mature framework for Discord interactions. Bundling FastAPI directly into the bot process avoids the need for Redis pub/sub.
Why SQLite?
Lightweight, single-file, zero-dependency. Perfectly fits the scale of a single-developer workspace.