Sessions¶
Persistent multi-turn session management. A session maps to a Fly machine + volume pair that persists between prompts.
Session
dataclass
¶
A persistent Claude Code session on Fly.io.
Tracks the machine, volume, and session metadata needed to resume a multi-turn conversation.
Attributes:
| Name | Type | Description |
|---|---|---|
session_id |
str
|
UUID identifying the Claude Code session. |
machine_id |
str
|
Fly machine ID (stopped between turns). |
volume_id |
str
|
Fly volume ID (persists workspace + session transcripts). |
app_name |
str
|
Fly app the session belongs to. |
region |
str
|
Fly region for machine + volume. |
created_at |
str
|
When the session was created (ISO 8601). |
ttl_seconds |
int
|
Optional time-to-live in seconds. 0 means no TTL (explicit destroy only). Caller is responsible for enforcing. |
expired
property
¶
Check if the session has exceeded its TTL.
Returns False if ttl_seconds is 0 (no TTL set).
create_session
async
¶
Create a new session: volume + machine + first prompt.
Creates a Fly Volume, then a machine with auto_destroy=False
and the volume mounted at /data. Runs the first prompt using
--session-id to pre-assign the UUID. Returns the session
handle and the first turn's result.
The machine is left in stopped state after the first turn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
Fly app to create the session in. |
required |
config
|
MachineConfig
|
Machine config (must include |
required |
name
|
str | None
|
Optional machine name. |
None
|
volume_size_gb
|
int
|
Volume size in GB (default 1). |
1
|
ttl_seconds
|
int
|
Optional TTL in seconds (0 = no TTL, explicit destroy only). |
0
|
token
|
str | None
|
Explicit Fly API token. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Session, RunResult]
|
A tuple of (Session, RunResult) for the first turn. |
Source code in flaude/session.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
destroy_session
async
¶
Destroy a session — machine and volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
Fly app the session belongs to. |
required |
session
|
Session
|
The session to destroy. |
required |
token
|
str | None
|
Explicit Fly API token. |
None
|