Skip to content

feat(session): add /handoff command for cross-platform session transfer#22726

Closed
kshitijk4poor wants to merge 1 commit into
mainfrom
feat/session-handoff
Closed

feat(session): add /handoff command for cross-platform session transfer#22726
kshitijk4poor wants to merge 1 commit into
mainfrom
feat/session-handoff

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

What

Adds /handoff <platform> — a CLI slash command that hands your current session off to a messaging platform's home channel. The session becomes available on that platform and continues with full conversation context.

How

Files (5 files, +297 lines)

File Change
hermes_state.py handoff_pending + handoff_platform columns (declarative, auto-migrates), 3 helper methods
cli.py _handle_handoff_command — marks session, sends notification via send_message
hermes_cli/commands.py CommandDef entry
gateway/run.py _handle_message_with_agent — checks for pending handoffs on new sessions, injects transcript
tests/hermes_cli/test_session_handoff.py 8 tests covering DB ops + command registration

Supported platforms

telegram, discord, slack, whatsapp, signal, matrix

Architecture rationale

No identity binding, no tokens, no QR codes. The gateway's configured home channel IS the authority. This follows the same pattern as all cloud-backed tools (ChatGPT, Claude Code) but uses Hermes's existing gateway identity layer instead of a cloud account.

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: feat/session-handoff vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 7890 on HEAD, 7888 on base (🆕 +2)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/hermes_cli/test_session_handoff.py:8: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 4175 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

Adds /handoff <platform> CLI command that queues the current session for
resume on the configured home channel of any messaging platform.

CLI side:
- /handoff telegram — marks session in shared DB, sends summary to
  the Telegram home channel via send_message
- /handoff discord — same for Discord
- Supports telegram, discord, slack, whatsapp, signal, matrix

Gateway side:
- On new session creation, checks for pending handoffs for the
  incoming message's platform
- If found, loads the CLI session's full conversation history and
  injects it into the context prompt as a handoff transcript
- Agent continues the conversation seamlessly

Files:
- hermes_state.py: handoff_pending, handoff_platform columns + helpers
- cli.py: _handle_handoff_command dispatch + handler
- hermes_cli/commands.py: CommandDef entry
- gateway/run.py: handoff detection in _handle_message_with_agent
- tests/hermes_cli/test_session_handoff.py: 8 tests
@kshitijk4poor kshitijk4poor force-pushed the feat/session-handoff branch from b87875f to a52c204 Compare May 9, 2026 18:00
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels May 9, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #23395 — your commit (ea0f4d4) was cherry-picked onto current main with your authorship preserved in git log, then I rewrote the gateway-side flow on top so the handoff happens immediately rather than waiting for a real user message. The /handoff command surface and DB schema scaffolding you wrote are the foundation; the runtime now creates a fresh thread on Telegram/Discord/Slack, switch_sessions the destination key onto your CLI session_id (so the full role-aware transcript replays via load_transcript instead of a flat-text injection), and dispatches a synthetic user turn so the agent confirms it's working in the new place. Thanks for kicking this off — the schema-driven design made the rewrite straightforward.

#23395

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants