Skip to content

feat: Profile-based channel routing for single-gateway multi-agent - #20018

Closed
Burgunthy wants to merge 1 commit into
NousResearch:mainfrom
Burgunthy:feat/profile-routing
Closed

feat: Profile-based channel routing for single-gateway multi-agent#20018
Burgunthy wants to merge 1 commit into
NousResearch:mainfrom
Burgunthy:feat/profile-routing

Conversation

@Burgunthy

Copy link
Copy Markdown
Contributor

Summary

Implements profile routing (closes #18423) — allows a single gateway instance to route specific channels/threads to different Hermes profiles, each with their own model, provider, and persona.

Use case: Run one Discord bot that behaves as a trader in #stock, a wiki curator in #knowledge, and the default assistant everywhere else — without multiple bot tokens or gateway processes.

How it works

# config.yaml
profile_routes:
  - name: trader
    platform: discord
    chat_id: "1467470389465583668"
    profile: trader
    enabled: true

When a message arrives, the gateway matches its source against configured routes (priority: thread > chat > platform). A matched route:

  1. Scopes the session key to agent:{profile}: (isolated from main)
  2. Loads ~/.hermes/profiles/{name}/config.yaml overrides (model, provider, etc.)
  3. Passes everything through the normal agent pipeline

No routes configured = identical behavior. Fully backward-compatible.

Changes

File Description
gateway/profile_routing.py NewProfileRoute dataclass, route parsing, priority-based matching
gateway/config.py GatewayConfig.profile_routes field + YAML parsing
gateway/session.py build_session_key() accepts optional profile_name (defaults to "main")
gateway/run.py Route matching in _handle_message() + profile config loading in _handle_message_with_agent()
tests/gateway/test_profile_routing.py New — 16 tests

Test results

  • New tests: 16/16 passed
  • Existing session tests: 93/93 passed ✅ (backward-compatible)

Related issues

Design notes

  • In-process routing (not subprocess) — lower latency, simpler ops
  • Session keys are isolated per profile: agent:main:discord:... vs agent:trader:discord:...
  • Profile config overrides (model, provider, api_key, base_url, api_mode) merge with session-level /model overrides
  • Route matching is lazy-initialized on first message, then cached
  • SOUL.md and profile-specific memories are loaded via existing profile infrastructure

Implements profile routing (issue #18423) — allows a single gateway
instance to route specific Discord channels/threads to different
Hermes profiles, each with their own model, provider, and persona.

Changes:
- gateway/profile_routing.py (NEW): ProfileRoute dataclass, route
  parsing, and priority-based matching (thread > chat > platform)
- gateway/config.py: GatewayConfig.profile_routes field + YAML parsing
- gateway/session.py: build_session_key() accepts optional profile_name,
  scoping session keys to agent:{profile}: instead of hardcoded main
- gateway/run.py: _handle_message() matches routes before session creation;
  _handle_message_with_agent() loads profile config.yaml overrides
  (model, provider, etc.) and merges them into agent runtime resolution
- tests/gateway/test_profile_routing.py (NEW): 16 tests covering parsing,
  specificity sorting, and matching edge cases

Backward-compatible: no routes configured = identical behavior.
Session keys with profile_name=None default to agent:main: as before.

Config example:
  profile_routes:
    - name: trader
      platform: discord
      chat_id: "123"
      profile: trader
      enabled: true
@Burgunthy

Copy link
Copy Markdown
Contributor Author

Closed by author — submitted to wrong repo.

@Burgunthy Burgunthy closed this May 5, 2026
@Burgunthy
Burgunthy deleted the feat/profile-routing branch May 5, 2026 03:12
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Profile routing for Discord

3 participants