-
Notifications
You must be signed in to change notification settings - Fork 15.5k
fix(discord): isolate autoThread thread context #856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(discord): isolate autoThread thread context #856
Conversation
- Re-key SessionKey to the created thread when autoThread creates a thread, preventing cross-thread context bleed.\n- Avoid parent-channel rolling history when autoThread is enabled and message is top-level (parent acts as launcher/index).\n- Small formatting cleanup.
6172dc2 to
cde802b
Compare
|
Updated branch after rebasing onto latest upstream/main and resolving conflicts from refactor. Should be up to date now. |
|
@codex review |
There was a problem hiding this 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: cde802b55b
ℹ️ 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".
| From: `group:${createdThreadId}`, | ||
| To: `channel:${createdThreadId}`, | ||
| OriginatingTo: `channel:${createdThreadId}`, | ||
| SessionKey: autoThreadKeys.sessionKey, | ||
| ParentSessionKey: autoThreadKeys.parentSessionKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid forking autoThread sessions from parent context
In the autoThread branch you now set ParentSessionKey to the parent channel. initSessionState in src/auto-reply/reply/session.ts uses ParentSessionKey to forkSessionFromParent, so a newly created thread still inherits the parent channel’s session history (which often contains context from other threads). That undermines the intended isolation for autoThread launcher channels and can still pollute thread context. Consider leaving ParentSessionKey unset (or skipping the fork) for auto-created threads so each thread starts clean.
Useful? React with 👍 / 👎.
|
Replying to #856 (comment) Thanks — you’re right that Concrete example of the “pollution” risk:
What this does not do: it does not cause live mixing between concurrently active threads; ongoing messages are isolated because each thread has its own Tradeoff:
|
|
Squashed and merged to
|
Build reply/session context once (no post-hoc ctx mutation) and type into the actual delivery target. Thanks @davidguttman. Co-authored-by: David Guttman <[email protected]>
|
Landed on
Gate: Thanks @davidguttman! |
Build reply/session context once (no post-hoc ctx mutation) and type into the actual delivery target. Thanks @davidguttman. Co-authored-by: David Guttman <[email protected]>
What this fixes
Discord
autoThreadpreviously replied into newly-created threads while keeping the parent channel session/context, so concurrent threads polluted each other.Changes
autoThreadcreates a new thread, re-keySessionKey(andFrom/To) to the created thread channel so each thread has isolated context.autoThreadlauncher channels, skip parent-channel rolling history for top-level messages (the parent behaves like an index/launcher; rolling history is usually unrelated thread starters).Expected behavior
ThreadStarterBodyhandling.