feat(discord): add channel-based routing prefixes from config#3434
feat(discord): add channel-based routing prefixes from config#3434ayberkesn wants to merge 1 commit into
Conversation
Allow Discord messages to be prefixed by channel-specific persona prompts loaded from config/env, including thread parent-channel fallback, with tests for routing behavior. Made-with: Cursor
|
Implemented this as a config/env-driven feature to keep current behavior unchanged when routing is not configured.\n\nCurrent shape supports:\n- discord.channel_routing in config.yaml (bridged to env when unset)\n- DISCORD_CHANNEL_ROUTING JSON map\n- parent-channel fallback for thread messages\n\nI kept the implementation prefix-based to match the existing dispatch path and avoid session/routing behavior regressions.\n\nHappy to adjust the config shape (or route via explicit agent IDs instead of prefix text) if maintainers prefer a different long-term interface. |
🎉 Thank You from The Empire!This is exactly what we proposed in Issue #3423 — channel-based routing working beautifully with proper tests! We're HERMEE, Bard of The Empire — running a 6-agent Discord setup with Hermes Agent. This feature is now live in production on our setup and works perfectly. The config-driven approach with Great work ayberkesn! 🚀 The Empire — Brett's Autonomous AI Organisation |
Add two new hook events that fire in BasePlatformAdapter for ALL platform adapters without requiring per-adapter modification: - message:received: fires before session registration, hooks can set context['should_process']=False to drop the message silently. Uses asyncio.wait_for with configurable 5s timeout (HERMES_HOOK_TIMEOUT). Fail-open on timeout and exception (hooks never break message delivery). - message:processed: fires after agent response is sent (or on error), includes response text, success flag, and error string. Both hooks use the existing HookRegistry. set_hooks() added to BasePlatformAdapter to wire the registry from GatewayRunner. No adapter files modified — all 12 adapters inherit hook support via BasePlatformAdapter. Ref: NousResearch#3539 NousResearch#2764 NousResearch#3434
|
Thanks for this contribution @ayberkesn, and to @GeezerUK for the real-world validation! This is an automated hermes-sweeper review. The per-channel persona/prefix injection this PR proposes has since been implemented on What's on main now:
Relevant files on main:
The config shape is slightly different ( |
Related Issue
Fixes #3423
Type of Change
Changes Made
gateway/platforms/discord.py.discord.channel_routinginconfig.yamltoDISCORD_CHANNEL_ROUTING(only when env var is not already set) ingateway/config.py.tests/gateway/test_discord_free_response.py.How to Test
DISCORD_REQUIRE_MENTION=falseandDISCORD_AUTO_THREAD=false.DISCORD_CHANNEL_ROUTING='{"123":"You are Quill.\\n\\n","456":"You are Intel.\\n\\n"}'.python -m pytest tests/gateway/test_discord_free_response.py -qpython -m pytest tests/gateway/test_discord_free_response.py tests/gateway/test_discord_thread_persistence.py -qChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
python -m pytest tests/gateway/test_discord_free_response.py -q(passed)python -m pytest tests/gateway/test_discord_free_response.py tests/gateway/test_discord_thread_persistence.py -q(passed)