AgentIM — Rust Multi-Channel IM Bridge
AgentIM is a Rust bridge that connects chat platforms to a local AI agent backend (Codex). It supports 8+ platforms through webhooks and long polling, with session persistence, context limits, and routing rules.AgentIM
Rust IM bridge — 8+ platforms, session persistence, health endpoints.
Supported Platforms
Tech Stack
Architecture
Key Design Patterns
Platform Abstraction
Each platform handler implements a common trait:Session Persistence
User sessions are stored inDashMap — a lock-free concurrent hashmap:
DashMap provides sharded locks internally, so concurrent reads/writes from multiple Tokio tasks don’t block each other. Much faster than
Mutex<HashMap> for IM workloads.Context Trimming
Chat history grows over time. AgentIM trims context to stay within token limits:Webhook Signature Verification
Each platform has its own signature scheme. AgentIM validates before processing:Routing Rules
Channel-based routing lets you direct messages to different behaviors:Docker Deployment
Health Endpoints
Best Practices
- Platform trait abstraction — Common interface per platform, easy to add new ones
- DashMap for concurrent state — Lock-free, fast for multi-platform message handling
- Context trimming — Keep history within token limits to avoid runaway memory
- Webhook signature verification — Always validate before trusting inbound messages
- Health + readiness endpoints — Let orchestrators (Docker, K8s) monitor service state
- Shared-secret auth — Simple but effective for internal service communication
- Tokio full features — IM bridges need timers, I/O, and sync — don’t trim the runtime
References
- AgentIM repo — Full source code
- Axum Docs
- DashMap
- Codex app-server transport
