feat(telegram): add per-topic agent routing for forum groups [AI-assisted]

This feature allows different topics within a Telegram forum supergroup to route
to different agents, each with isolated workspace, memory, and sessions.

Key changes:
- Add agentId field to TelegramTopicConfig type for per-topic routing
- Add zod validation for agentId in topic config schema
- Implement routing logic to re-derive session key with topic's agent
- Add debug logging for topic agent overrides
- Add unit tests for routing behavior (forum topics + DM topics)
- Add config validation tests
- Document feature in docs/channels/telegram.md

This builds on the approach from PR #31513 by @Sid-Qin with additional fixes
for security (preserved account fail-closed guard) and test coverage.

Closes #31473
This commit is contained in:
Evgeny Zislis
2026-03-04 01:12:46 +02:00
committed by Ayaan Zaidi
parent 7f2708a8c3
commit 58bc9a241b
6 changed files with 338 additions and 4 deletions

View File

@@ -187,6 +187,8 @@ export type TelegramTopicConfig = {
systemPrompt?: string;
/** If true, skip automatic voice-note transcription for mention detection in this topic. */
disableAudioPreflight?: boolean;
/** Route this topic to a specific agent (overrides group-level and binding routing). */
agentId?: string;
};
export type TelegramGroupConfig = {