Routing
One-line summary
The routing system maps inbound messages to agent + session pairs through a multi-tier binding priority chain: peer > guild+roles > guild > team > account > channel > default.
Responsibilities
- Resolve which agent handles a message based on channel, account, peer, guild, team, and roles
- Build session keys that encode the full routing context (agent, channel, chat type, identity)
- Support DM session scoping (main, per-peer, per-channel-peer, per-account-channel-peer)
- Handle thread parent inheritance for nested contexts
- Manage identity linking across channels
Architecture diagram
Key source files
Session key format
Constraints: 64-char limit, path-safe, shell-friendly characters.
Binding priority chain
How it connects to other modules
- Depends on:
config/(bindings configuration),channels/(chat type normalization) - Depended by:
auto-reply/(resolves route before dispatching),sessions/(session key parsing)
My blind spots
- Identity linking — how cross-channel identity resolution works
- Caching behavior in
resolveAgentRoute()— whether results are cached - Legacy key migration — how old session key formats are handled
Change frequency
resolve-route.ts: Medium — new binding types added with featuressession-key.ts: Medium — new key formats for new session typesbindings.ts: Low — query utilities are stable