feat: forum topics get separate agent sessions#87
Conversation
Each Telegram forum topic now resolves to its own agent session: - group:-100123:topic:42 (instead of just group:-100123) - Messages in different topics maintain independent context - Non-forum groups unchanged (still group:<chatId>) Topic ID sourced from (priority order): 1. message.message_thread_id 2. thread.messageThreadId 3. Thread ID string (telegram:<chatId>:<topicId>) +3 tests (396 total green)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ca808b2ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /** Extract message_thread_id from thread ID string like "telegram:chatId:topicId" */ | ||
| function extractTopicFromThreadId(threadId: string | undefined): number | undefined { | ||
| if (!threadId) return undefined; | ||
| const parts = threadId.split(":"); |
There was a problem hiding this comment.
Guard topic parsing against non-string thread IDs
resolveAgentThreadId now always calls extractTopicFromThreadId(thread?.id) before any transport checks, but extractTopicFromThreadId assumes threadId is a string and unconditionally does threadId.split(":"). If a transport/event supplies a numeric or otherwise non-string thread.id, this throws at runtime and prevents message routing entirely, whereas the previous logic safely fell back to String(thread?.id ?? "main"). Please add a typeof threadId === "string" guard before splitting so non-string IDs don't crash routing.
Useful? React with 👍 / 👎.
Each Telegram forum topic now resolves to its own agent session. 396 tests green.