Skip to content

fix(discord): add initiator to handoff threads - #26872

Closed
whirmill wants to merge 1 commit into
NousResearch:mainfrom
whirmill:fix/discord-handoff-thread-membership
Closed

fix(discord): add initiator to handoff threads#26872
whirmill wants to merge 1 commit into
NousResearch:mainfrom
whirmill:fix/discord-handoff-thread-membership

Conversation

@whirmill

Copy link
Copy Markdown
Contributor

Summary

  • Adds an optional user_ids argument to handoff-thread creation so platforms with explicit thread membership APIs can include the initiating operator.
  • Implements best-effort Discord thread.add_user(...) for explicit handoff initiators.
  • Avoids falling back to all allowed Discord users, so automated handoff threads do not become noisy in multi-operator servers.

Testing

  • python -m pytest tests/gateway/test_discord_send.py -o 'addopts=' -q
  • Included in combined local convergence run: 272 passed

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter platform/slack Slack app adapter platform/telegram Telegram bot adapter labels May 16, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing Discord handoff discoverability. The underlying gap remains on current main: gateway/run.py:7501-7503 creates handoff threads without a member identity, and plugins/platforms/discord/adapter.py:5455-5531 has no membership step.

Problems

  • The proposed row.get("user_id") source cannot identify the normal CLI handoff initiator. Current agent-created rows explicitly use user_id=None in run_agent.py:600-608, and direct CLI row creation likewise omits it in cli.py:7091-7099; the new kwargs would therefore be empty in the primary /handoff flow.
  • The added unit tests exercise only the adapter API. Add an end-to-end _process_handoff test with a CLI-shaped row so the identity propagation is verified.
  • The Discord adapter moved from gateway/platforms/discord.py to plugins/platforms/discord/adapter.py in cc8e5ec2afbfd10a3cff4e710210dd9ecae64a33, so this needs a deliberate port.

Suggested changes

  • Establish a reliable destination Discord user identity when the handoff is requested, persist it with the handoff request, then pass that explicit identity to the plugin adapter.

Automated hermes-sweeper review.

Comment thread gateway/run.py
@@ -3923,9 +3923,21 @@ async def _process_handoff(self, row: Dict[str, Any]) -> None:
# synthetic turn still lands; just without thread isolation.
thread_name = f"Hermes — {cli_title}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

row["user_id"] is not populated for the normal CLI handoff flow: current agent-created rows pass user_id=None (run_agent.py:600-608) and CLI row creation omits it (cli.py:7091-7099). Persist a trustworthy destination Discord operator ID at request time, then test _process_handoff with that CLI-shaped row.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@whirmill

Copy link
Copy Markdown
Contributor Author

Superseded by the current-main replacement PR #65505: #65505

@whirmill

Copy link
Copy Markdown
Contributor Author

Superseded by current-main replacement PR #65505: #65505

@whirmill whirmill closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/discord Discord bot adapter platform/slack Slack app adapter platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants