DocsConnect a session
Sessions

Connect a session

Ask a Claude Code or Codex session to email itself to you. Close the session at your computer. Hand it off. Reply from your phone to continue the same session.

Note

Use @gent 0.5.0 or later.

Session commands are available in the published package. Upgrade with uv tool upgrade atgent, then run atgent start so the runner uses the new version. Check it with atgent status --human --wait-ready 30.

What you need

  • A working @gent setup from Getting started. The runner must be running and ready.
  • A persisted Claude Code or Codex session in a project folder from your config.
  • The setup uses the local MCP server and the native identity hooks below.

You do not need a website account. The CLI, MCP server and email work without the dashboard.

Add the MCP server

Register the local server with your agent. The server runs on your computer over stdio and opens no network port.

$ claude mcp add atgent -- atgent mcp$ codex mcp add atgent -- atgent mcp

If your runner uses a config outside the default location, add --config /absolute/path/config.json before mcp. The server offers attach_session, list_sessions, session_status and email_session.

Turn on the identity hooks

The MCP server alone cannot identify the conversation calling it. The hooks give the agent its exact session ID and project, so the agent never guesses from the newest transcript.

$ atgent integrate claude --output ~/.claude/settings.json$ atgent integrate codex --output ~/.codex/hooks.json

Without --output, the command prints the hooks and changes nothing. With it, @gent adds its hooks and keeps your existing ones. If you use CLAUDE_CONFIG_DIR or CODEX_HOME, write to that profile's file. Trust the new hooks if your agent asks, then restart or resume the session.

Ask for the email

In the session, ask: email me this session. The agent connects the session and @gent queues an opening email in a new thread. No second agent starts.

  1. 1Ask in the session. With the MCP server and hooks enabled, the agent connects its own session.
  2. 2The opening email. It starts a new thread named after the session.
  3. 3Hand it off. Close the local session first, then run atgent handoff with the task ID.
  4. 4Reply to continue. The reply runs in the same session on your computer.

Hand it off

After you connect a session, the terminal still controls it. You can reply from your phone at once, but email replies wait. Close the local session, then run:

$ atgent handoff 7c41e2d0

Use your own task ID from the opening email. The handoff tells @gent that the local session is closed. @gent cannot see every agent process, so it never releases a session on a timer. Do not keep working in the local session after the handoff.

Note

Email turns use your @gent permissions.

The handed-off session runs with the agent permissions and sandbox in your @gent config. It does not carry over permission grants from the local session.

Connect a session without hooks

If your agent version or an admin policy blocks hooks, connect the session with its exact session ID and project alias:

$ atgent attach --agent claude --session SESSION_UUID --project main --title 'Finish the settings page'

A session ID alone is not enough. @gent checks that the session exists in the configured agent profile and belongs to that project folder. Deleted, unsaved and ephemeral sessions cannot be connected.

Optional: list new sessions automatically

Add --auto-register to also install a Stop hook. After each completed turn, it lists that session in atgent list, the email directory and a paired dashboard. It sends no email.

$ atgent integrate claude --auto-register --output ~/.claude/settings.json

The hook covers only sessions in projects and profiles from your config. It does not import older sessions, and it never releases a session from the terminal. To stop it, remove only the @gent Stop handler from your agent's hooks.

If something waits

  • A reply does nothing. The session is still held locally. Close it and run atgent handoff TASK_ID.
  • Handoff refuses. A session opened with atgent open is still running. Close it first.
  • No opening email. Check that the runner is ready with atgent status --human. A queued email is not proof of delivery.
  • Commands refuse an older runner. Run atgent start after upgrading.

The computer must stay awake and online with the runner active. See Troubleshooting for runner messages.

Checked against @gent 0.5.0.