fix(discord): carry CLI handoff initiator into threads - #65505
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for rebuilding the Discord handoff change against the current architecture. The missing initiator path is real: current main calls create_handoff_thread without identity at gateway/run.py:7787.
Problems
hermes_state.py:7143repurposessessions.user_idas handoff transport. That field is durable gateway routing/ownership metadata (hermes_state.py:2029-2044) and persisted-session/resumeuses it for ownership checks (gateway/slash_commands.py:828-960). The existing TUI handoff caller still callsrequest_handoffwithout an ID (tui_gateway/server.py:6771), so this change would set that metadata toNULL.
Suggested changes
- Carry the Discord initiator in a handoff-specific field and read that field in
_process_handoff; preservesessions.user_id. - Add coverage for preserving an existing
user_idfor both explicit-initiator CLI handoffs and the no-initiator TUI/desktop call path.
Automated hermes-sweeper review.
| " handoff_platform = ?, " | ||
| " handoff_error = NULL " | ||
| " handoff_error = NULL, " | ||
| " user_id = ? " |
There was a problem hiding this comment.
sessions.user_id is durable gateway ownership/routing metadata, not handoff scratch state. This shared method is also called by tui_gateway/server.py without user_id, so this assignment clears existing identity. Please add a handoff-specific initiator field and leave sessions.user_id unchanged.
SummaryTwo open PRs address distinct failures in the CLI-to-gateway handoff path: #27326 propagates the originating workspace for Codex, while #65505 carries an explicit Discord initiator into newly created handoff threads. Their diffs target separate causes and both retain salvageable implementations, but each uses a persistence path identified by its visible keep-open review as needing rework. Related pull requests
Suggested consolidationKeep both PRs open with separate salvage paths: rework #27326 around Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 32 kB of PR diffs, 3 kB of issue/PR text, 1 kB of discussion (3 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
Summary
This is a current-main replacement for #26872 (
fix(discord): add initiator to handoff threads).The original PR attempted to read
row.user_id, but normal CLI/handoffrows do not contain the Discord initiator. This replacement makes the identity explicit at request time and carries it through the handoff state row and gateway to the current Discord plugin adapter./handoff discord [discord_user_id]with validation._process_handoffregression coverage.This branch is based on the current
mainand deliberately does not include the obsolete adapter paths or unrelated changes from #26873. It is also kept separate from #63459 so maintainers can coordinate the adjacent anchor/tracker work independently.Verification
scripts/run_tests.sh tests/gateway/test_discord_send.py tests/hermes_cli/test_session_handoff.py -q— 35 passedscripts/run_tests.sh tests/gateway/test_telegram_topic_mode.py tests/gateway/test_async_session_db.py tests/gateway/test_handoff_watcher_async_db.py -q— 62 passedruff checkon all touched Python filespython -m py_compileon all touched Python filesgit diff --checkSupersedes the implementation approach in #26872; the historical PR is intentionally not force-pushed.