Sessions¶
How sessions work¶
A session begins when you run fuseraft run. The orchestrator:
- Generates an 8-character hex session ID (e.g.
a3f92c1d) - Saves a checkpoint to
~/.fuseraft/sessions/<sessionId>.jsonafter every agent turn - Streams responses to the terminal as they arrive
- Marks the session complete when the termination strategy fires
If the run is interrupted for any reason (network error, Ctrl+C, process kill), the checkpoint is already saved up to the last completed turn.
Resuming a session¶
# Show a list of incomplete sessions and choose one
fuseraft run --resume
# Resume a specific session by ID
fuseraft run --resume a3f92c1d
The orchestrator re-injects the prior history into the group chat and continues from the next agent turn. The model receives the full conversation context (or a compacted summary if compaction fired).
You can resume with a different config or task — the session ID is what ties the checkpoint to the run, not the config file.
Session files¶
Sessions are stored at ~/.fuseraft/sessions/<sessionId>.json with owner-only read/write permissions (Unix mode 0600).
Checkpoint fields:
| Field | Description |
|---|---|
SessionId |
8-character hex identifier |
Task |
Original task string |
ConfigPath |
Path to the orchestration config used |
Messages |
All agent messages produced so far |
StartedAt |
UTC timestamp when session was first created |
LastUpdatedAt |
UTC timestamp of the most recent update |
IsComplete |
true once the session has run to completion |
Message fields:
| Field | Description |
|---|---|
AgentName |
Agent name, or "Human" for HITL injections |
Content |
Text content of the response |
Timestamp |
UTC timestamp |
TurnIndex |
Zero-based turn index within the session |
Role |
"assistant" for agent turns, "user" for HITL injections |
Usage |
Token counts and estimated cost (null for HITL turns) |
IsCompactionSummary |
true if this message is a compaction summary |
Managing sessions¶
# List all incomplete sessions
fuseraft sessions
# List all sessions including completed
fuseraft sessions --all
# Delete a session by ID
fuseraft sessions --delete a3f92c1d
# Purge all completed sessions
fuseraft sessions --delete all
Human-in-the-loop (HITL)¶
Run with --hitl to pause after every agent turn and review before continuing:
After each turn you see:
| Input | Effect |
|---|---|
| Enter | Continue to the next agent turn |
| Any text | Inject that text as a user message, then continue |
q |
Save checkpoint and exit cleanly |
Injected messages are saved in the session checkpoint with Role: "user" and AgentName: "Human". They are re-injected on resume so the conversation context is complete.
Token tracking and cost estimation¶
Token counts and estimated costs are tracked per turn and accumulated for the session.
Costs appear in --verbose mode and in the --output transcript. The total session cost is displayed when the run completes.
Per-turn data:
| Field | Description |
|---|---|
InputTokens |
Tokens in the model's input (prompt + history) |
OutputTokens |
Tokens in the model's output |
CostUsd |
Estimated cost for this turn in USD |
Cost cap: Set MaxCostUsd in the config to stop the run before the next turn if cumulative cost exceeds the limit. The session is saved and can be resumed later.
Custom pricing: Override or extend the built-in pricing table by creating ~/.fuseraft/pricing.json:
Values are input and output price per 1,000 tokens in USD. If a model is not in the table, tokens are counted but cost shows as —.
Conversation compaction¶
Long-running sessions will eventually exceed the model's context window. Compaction automatically summarizes old turns to keep the session alive indefinitely.
How it works:
- When the message count reaches
TriggerTurnCount, compaction fires. - An LLM call summarizes all turns except the most recent
KeepRecentTurns. - The old turns are replaced by a single summary message.
- The checkpoint is saved with the compacted history.
- The session continues with the summary providing context for older work.
TriggerTurnCount must be greater than KeepRecentTurns. An error is thrown at startup if this constraint is violated.
Compaction model: By default, the first agent's model is used for generating summaries. Override with Compaction.Model:
Cost accounting: The summary message's cumulative cost includes all the turns it replaced, so budget tracking remains accurate after compaction.
Saving transcripts¶
Write the full session transcript to a Markdown file:
The file includes every agent turn with agent name, timestamp, content, and per-turn token/cost data. Useful for review, sharing, or archiving completed sessions.