feat(telegram): route forum topics to Hermes profiles#18510
Conversation
|
Bumping this for visibility, this is a great improvement for Hermes |
Test Report: Topic Profile Routing (PR #18510)Successfully tested this PR with a real Telegram supergroup setup — it works! Here are the details: Setup
What works ✓
Issues encountered1. Agent cache doesn't bust on SOUL.md changes (critical) Workaround: Delete the profile's 2. ContextVar propagation gap in tool execution (critical) Workaround: Pre-populate all profile SOUL.md files before starting the gateway. Avoid asking routed agents to modify their own identity files. 3. Profile config must stay minimal Workaround: Keep profile configs minimal — only SummaryThe core routing works well and is production-ready for the happy path. The two cached-agent issues are solvable with the workarounds above. A proper fix would involve:
Thanks for this PR — it bridges the last major gap between Hermes and multi-agent forum-topic setups! 🚀 |
|
Update on the topic-profile routing hardening work: Covered now:
Validation run locally:
@Donmeusi if you have time, it would be very helpful to retest your same Telegram supergroup setup with the latest branch. In particular, the previous workarounds should no longer be necessary:
hope this helps |
|
Heya. How can we help finalize this work? |
|
Ho hey Teknium ; thanks for checking in. I reproduced the current
I tested that resolution in a scratch merge against current
Result: What remains before merge:
And I guess we will be good Follow-up pushed: I re-checked the reported gaps against the current PR and made one targeted hardening fix plus regression coverage:
Important behavior note: this PR still intentionally does not proxy gateway tools/MCP servers into routed profiles by default. That keeps the isolation boundary explicit and avoids leaking gateway secrets/capabilities into a specialized profile. A true gateway tool bridge should be a separate opt-in feature with its own security review and tests. Unless you have other ideas/needs. Validation run locally:
|
f5c0b3c to
c03ea6a
Compare
🧪 E2E Field Report — Telegram Topic Profile Routing (7 Topics)Environment: macOS (Darwin ARM64), Hermes Gateway with Telegram forum topic routing enabled, latest PR branch including Verified against latest fixes (comment #4372690748)
New Profile Created Under Latest Branch — News Agent (Topic Profile)Created a new topic-routed profile using the exact PR workflow (no pre-PR workarounds): mkdir -p ~/.hermes-topic-profiles/<profile>
# config.yaml — fully declarative: model, memory, toolsets, skills
# SOUL.md — English system instructions, agent responds in German
# .env — API keys onlyKey observation: Full declarative configs work without falling back to the main profile. Cron-Routing as Stress Testschedule: '0 7 * * *'
deliver: 'telegram:CHAT_ID:THREAD_ID'The scheduler resolves the delivery target into the isolated profile context autonomously — no interactive message handler required. Result: profile context built correctly, tools scoped to routed profile. Edge Cases Discovered1. FUSE Deadlock on macOS + Cloud Storage Mount When routed profiles write to cloud-mounted filesystems (macOS FUSE-based Google Drive, iCloud, etc.), heavy I/O can deadlock ( 2. New profiles implicitly inherit 3. ContextVar Tool Propagation (known Python limitation) Hermes file-write tools ( Test Checklist
ConclusionPR #18510 is production-ready for Telegram topic-to-profile routing. All reported gaps from the initial E2E test are addressed by the latest fixes. No pre-PR workarounds are required anymore. Ready for merge once the current merge conflicts with Possible follow-up: an opt-in gateway tool bridge for routed profiles that need gateway-level MCP servers without duplicating configuration. |
|
@teknium1 |
|
ayoahha everybody is waiting for this. Thanks for pushing it. And hope to be merged in the next rel |
|
Update: rebased/merged the branch with current Current status:
The PR still shows “workflows awaiting approval”, so CI cannot run until a maintainer approves the fork workflow run. Could a maintainer please approve the workflows when convenient? |
Regression Report — Merge Commit
|
Thanks @Donmeusi I checked this carefully But your report looks accurate for the previous merge attempt you tested, but the current PR head is now: On that head,
I also re-checked the remote branch content directly and reran the targeted profile routing tests locally:
So I believe the regression you saw was from the previous head, not the current PR branch. Could you retest against One more note: GitHub Actions still have not actually run. The current workflow runs are all |
|
@ayoahha Thanks for the quick turnaround. We retested against Setup: Real Telegram supergroup with forum topics, Topic 10 → profile What works:
What does not work:
We suspect an ordering issue in the session lifecycle (SessionDB initializes or reuses Should I open a separate issue for this, or does it fit within the scope of this PR? |
Thanks @Donmeusi . I think we are in the PR scope, so I fixed the ordering issue you reproduced on Root cause: the adapter could compute its active-session/batch key from What changed:
Targeted verification:
You can test again and tell me |
|
Update: Topic-profile routing is now working successfully on our end after a clean reinstall of Hermes and checking out this branch. We have set up multiple sub-agents, each with their own isolated profile home containing A few things we learned during setup that might help others:
The isolation works well: each agent has its own sessions, memory, and state. Looking forward to seeing this merged! Thanks for the great work on this feature. |
|
Great great thanks @Donmeusi for the real Telegram supergroup retest and for documenting the setup findings. That was very helpful for separating actual routing bugs from profile-isolation configuration details. I merged latest What was preserved:
I also added a small non-blocking warning for misplaced Local targeted verification:
CI still needs maintainer approval for fork workflows. |
|
I really hope this will be merged soon, I've been waiting for this. And btw it isn't a 'P3' at all. |
6cc47e6 to
753ef35
Compare
|
Hi maintainers, quick status update on this PR. Why this matters:
All targeted tests pass locally. I also ran a live Telegram Bot API smoke test covering as much as I can previous @Donmeusi tests. Could a maintainer approve the pending workflows so CI can run on this fork PR? If the scope is too large to review in one pass, I’m also happy to split this into smaller PRs, but the current branch is structured around the conflict-resolution + routing/isolation hardening needed for this feature to be safe. |
6dfc751 to
46c73da
Compare
|
After a huge update of the team on telegram, I made some improvements The last updates rebase the Telegram topic-to-profile routing work on the latest upstream What changed:
Why: Validation:
I really hope some maintainers will find some time to launch the CI. |
46c73da to
a7e51a4
Compare
Route Telegram forum topics through scoped Hermes profiles and keep runtime, tool, credential, and fixture isolation aligned with profile selection.
a7e51a4 to
ad5f2ca
Compare
|
Merge conflict analysis with current I tested merging Critical conflict files for topic-profile routing:
Additional utility conflicts: The feature is actively used in production (multi-agent Telegram groups with isolated profiles per topic). As |
|
Thanks @Donmeusi for this last detailed testing and the latest conflict analysis. To all, Since this was opened, No hard feelings here. I understand maintainers have to prioritize. But from my side, I will no longer maintain or rebase this PR. If the team or another contributor still wants this feature, please feel free to take over the branch, cherry-pick parts of it, or close this PR and restart from a smaller scoped implementation. |
What does this PR do?
Adds Telegram forum topic routing to existing Hermes profiles.
A single Telegram bot can now route
chat_id + message_thread_idto a named Hermes profile, so each topic can use its own profile config, model,SOUL.md, system prompt, toolsets,.env, memory, sessions, and state.Unconfigured chats/topics keep the current behavior.
Related Issue
Fixes #10143 and #4321. Refs #9514 and #7517.
Type of Change
Changes Made
gateway/platforms/telegram.py: resolve Telegram forummessage_thread_idto a routed profile.gateway/platforms/base.py: add validation/normalization fortelegram.topic_profiles.gateway/run.py: run routed messages under the target profile home/config/env.gateway/session.py: include profile in Telegram session keys.hermes_cli/*,run_agent.py: allow profile-scoped env/runtime provider resolution without mutating globalos.environ.scripts/setup_topic_routing_sandbox.sh: add safe local sandbox helper.Example:
How to Test
Result:
158 passed.Manual sandbox validation was also run with a separate Telegram test bot:
memories/MEMORY.mdChecklist
Code
pytest tests/ -qand all tests passHERMES_HOME, Telegram test botDocumentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/A