#7224: feat(telegram): inherit forum topic bindings from parent group
channel: telegram
Cluster:
Session Management Enhancements
## Summary
When a Telegram forum topic message doesn't match a direct peer binding, now checks if the parent group has a binding and uses that agent.
This enables multi-agent setups where forum topics inherit their parent group's agent binding automatically, consistent with Discord thread behavior added in #3892.
## Problem
In Telegram forum groups with topics enabled, messages have a peer ID like `-1003726751869:topic:42`. If you configure a binding for the group ID `-1003726751869`, topics don't inherit that binding and fall back to the default agent.
## Solution
Pass `parentPeer` (the group ID without `:topic:N` suffix) to `resolveAgentRoute` for forum topic messages, similar to how Discord threads pass their parent channel.
## Changes
- `src/telegram/bot-message-context.ts`: Pass parentPeer for forum topics
- `src/telegram/bot.ts`: Pass parentPeer in reaction handler for forum topics
- `src/telegram/bot-native-commands.ts`: Pass parentPeer for native commands in forum topics
- `src/routing/resolve-route.test.ts`: Add tests for Telegram forum topic binding inheritance
- `CHANGELOG.md`: Add changelog entry
## Testing
- Added 3 new tests for Telegram forum topic binding inheritance
- All existing tests pass
- Manually tested with a Telegram forum group
## Related
- #3892 - Discord thread parent binding inheritance (same pattern)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates Telegram routing so forum topic messages (which have peer IDs like `-100...:topic:N`) can inherit agent bindings from their parent group when there is no direct topic binding. It does this by passing a `parentPeer` (the base group peer) into `resolveAgentRoute` from three Telegram entry points: message context building, reaction handling, and native commands.
It also adds routing tests covering Telegram forum topic inheritance and records the change in the changelog. This aligns Telegram forum topic behavior with the existing `parentPeer` inheritance mechanism used for Discord threads in `src/routing/resolve-route.ts`.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but there is at least one concrete test/type issue to fix before it will pass CI reliably.
- Runtime logic change is small and uses an existing routing feature (`parentPeer`) consistently across Telegram handlers, but the new/modified tests appear to use an incorrect config type name (`MoltbotConfig`) that can break type-checking.
- src/routing/resolve-route.test.ts; CHANGELOG.md
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#16441: feat: add topicId matching to bindings for Telegram forum topics
by alextnetto · 2026-02-14
82.6%
#6192: Telegram: fix DM Topics thread routing
by ViffyGwaanl · 2026-02-01
78.7%
#6457: fix(telegram): register commands for group scope + preserve topic t...
by dae-sun · 2026-02-01
78.4%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
77.3%
#14359: fix: prefer named Telegram account over orphan 'default' in binding...
by itsGustav · 2026-02-12
77.3%
#6084: Add dynamic Telegram agent routing for DM and groups
by Alfonsxh · 2026-02-01
77.2%
#11920: Telegram: create forum topics via message tool (thread-create)
by larsderidder · 2026-02-08
76.5%
#7058: feat(telegram): add channel_post handler for broadcast channels
by waifu7498173 · 2026-02-02
76.3%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
75.9%
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
75.8%