Repository navigation
Description
What problem does this solve?
The #910 gateway (Telegram first, then Discord) forwards chat to tole serve, but there is no contract for routing a message that mentions a persona — "@Market-research cek kondisi pasar X" — to the right profile session. Today a client must know profile names and call POST /sessions {"profile": ...} itself. The desired UX: mention a handle in chat, the gateway routes the message to that persona's session, the reply lands back in the thread. Personas must be mentionable WITHOUT code changes (dynamic roster — 28 profiles today, growing).
Proposed solution
Config-driven mention routing in the gateway; no tole-core change expected:
- Mapping table
[gateway.mentions]in the gateway config:handle → profile name(e.g.market-research = "market-research"). Default = identity mapping (handle == profile name): adding[profiles.newname]toconfig.tomlmakes@newnameroutable immediately — the dynamic requirement. - Resolution order: explicit table entry > identity mapping (profile exists) > configured fallback profile + a notice line in the reply. An unknown handle never silently becomes a generic session (auditability).
- Session policy: one durable session per persona (resume by stored session id), matching the per-profile
memory_roomisolation from feat(serve): choose a profile per session on create and resume (#740) #885 — a persona accumulates memory across mentions. A second mention while a turn is running queues by default; optional flag to open a parallel session instead. - Reply routing: answers and approval requests from a persona session surface in the chat/thread the mention came from (feat(cron): outbound signed webhook delivery target for cron results and approval requests #911 outbound webhooks + feat(webhook_out): a turn-finished event, so a gateway needs no polling after an allow #962 turn-finished event).
- Security: mention routing never widens the tool roster — the session keeps its profile's own config (feat(serve): choose a profile per session on create and resume (#740) #885 isolation); gateway→serve stays behind the existing bearer auth; no new trust boundary.
Alternatives considered
- Hardcode a fixed @-command list in the gateway: rejected — every persona addition would need a gateway release; violates the dynamic roster requirement.
- Parse @mentions inside tole-core (
serveroutes them itself): rejected for v1 — the core stays single-lane and transport-agnostic (v0 identity); mention syntax is a chat-gateway concern. Revisit only if a second gateway needs identical semantics. - LLM-based intent routing (a model picks the persona from an unmentioned message): rejected for v1 — non-deterministic, costs tokens; explicit mentions are cheap and auditable. Can layer on later for messages without a mention.
Acceptance criteria
- Adding
[profiles.newname]to config makes@newnameroutable with zero gateway changes (identity mapping). - An explicit
[gateway.mentions]entry overrides identity mapping; an unknown mention falls back per config and says so in the reply. - Two mentions of the same persona in sequence land in the same session (memory continuity verified through its
memory_room). -
Parallel mentions of different personas run on independent sessions concurrently.Amended 2026-11-19 (owner decision, feat(gateway): default (fallback) session + HITL escalation suggestions; multi-mention folds into one discuss run #977): a message mentioning several personas folds into ONE discuss run with that participant set — not N independent sessions. Single-persona mentions keep one durable session each; two mentions of different personas in separate messages still run concurrently on their own sessions. - An approval raised by a persona session surfaces in the origin chat (feat(cron): outbound signed webhook delivery target for cron results and approval requests #911/feat(webhook_out): a turn-finished event, so a gateway needs no polling after an allow #962 path).
- The mention routing table is documented in the gateway README, and the gateway's doctor output lists the mentionable profiles.
Parent: #910. Related: #885 (profile + memory_room), #962 (turn-finished webhook), #911 (outbound webhooks), #949 (desktop over the same serve API).
Activity