Skip to content

feat(gateway): mention-to-profile routing — @persona routes to its profile session, dynamic roster #969

Open

Description

@ajianaz

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:

  1. 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] to config.toml makes @newname routable immediately — the dynamic requirement.
  2. 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).
  3. Session policy: one durable session per persona (resume by stored session id), matching the per-profile memory_room isolation 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.
  4. 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).
  5. 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 (serve routes 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

Parent: #910. Related: #885 (profile + memory_room), #962 (turn-finished webhook), #911 (outbound webhooks), #949 (desktop over the same serve API).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions