> ## Documentation Index
> Fetch the complete documentation index at: https://www.agentworldprotocol.com/llms.txt
> Use this file to discover all available pages before exploring further.

# session.close / session.resume / session.transfer / session.state

> Ending, resuming, and handing off sessions, and the transition notification.

## session.close

No params. Pre-execution actions → `cancelled` (`session_closed`); `executing` actions → `cancelling` → `cancelled` after safe abort (AWP-SES-006). The embodiment is released after safe state (AWP-EMB-002). Result `{}`.

## session.resume

Call after reconnecting and completing `initialize`, within `reconnect_window_ms` of the suspension.

<ParamField body="session_token" type="string" required>From `session.ready` (AWP-SEC-003).</ParamField>
<ParamField body="last_status_seq" type="integer" required>Highest `status_seq` the agent has processed; `0` if none (AWP-CTL-008).</ParamField>

```json awp:session-resume theme={null}
{ "jsonrpc": "2.0", "id": 3, "method": "session.resume",
  "params": { "session_token": "st_9f2…", "last_status_seq": 41 } }
```

**Result:** the same `session.ready` object as the original open, with the current `tick` (lockstep) and `safe_state: true|false` indicating whether the embodiment is in safe state (AWP-SAF-008). The world then replays every `action.status` and `world.event` with `status_seq > last_status_seq`, in order, before any live notification. Nothing that was executing resumes; submit new actions to move again.

**Errors:** 2003 (`AWP_SESSION_EXPIRED`: window passed or token invalid), 2005 (`AWP_SESSION_UNKNOWN`: the world no longer holds this session, e.g. it restarted; treat the session as closed, AWP-SES-008), 2004 (`AWP_SESSION_EXISTS`: this connection already carries a session).

## session.transfer

Current holder calls `session.transfer` with optional `{ expires_in_ms }` (default 30000) and receives `{ transfer_token, expires_in_ms }` for handoff; the receiver passes `transfer_token` to `session.open` with `takeover: true` (AWP-EMB-003). In-flight actions of the previous holder end `preempted`. Transfer tokens are single-use and redacted in the audit log (AWP-AUD-006).

```json awp:session-transfer-result theme={null}
{ "transfer_token": "tt_4c1…", "expires_in_ms": 30000 }
```

## session.state (notification)

World → Agent on every transition from `Ready` onward (AWP-SES-007). Shares the `status_seq` sequence with `action.status` and `world.event`, so a `suspended` transition the agent could not receive is replayed after `session.resume`.

<ParamField body="state" type="string" required>`ready`, `active`, `suspended`, or `closed`.</ParamField>
<ParamField body="status_seq" type="integer" required>Shared per-session sequence (AWP-CTL-008).</ParamField>
<ParamField body="ts_mono_ns" type="integer" required>Time of the transition.</ParamField>
<ParamField body="reason" type="string">`opened`, `first_activity`, `connection_lost`, `resumed`, `session_closed`, `window_expired`, `world_shutdown`, or `transferred`.</ParamField>

```json awp:session-state theme={null}
{ "jsonrpc": "2.0", "method": "session.state",
  "params": { "state": "suspended", "status_seq": 42, "ts_mono_ns": 913020000000, "reason": "connection_lost" } }
```
