Skip to content

feat: forum topics get separate agent sessions#87

Merged
royosherove merged 1 commit intomainfrom
feat/forum-topic-sessions
May 10, 2026
Merged

feat: forum topics get separate agent sessions#87
royosherove merged 1 commit intomainfrom
feat/forum-topic-sessions

Conversation

@royosherove
Copy link
Copy Markdown
Member

Each Telegram forum topic now resolves to its own agent session. 396 tests green.

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)
@royosherove royosherove merged commit 7b08e1e into main May 10, 2026
1 check passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/gateway/helpers.ts
/** 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(":");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant