Unflatten (restore) session
unflatten_sessionRestore a session to its pre-flatten state by re-inlining flattened tool results from backup, then remove the backup to leave no trace.
Instructions
Reverse a flatten: re-inline every flattened tool result back into the session JSONL from the backup, restoring the session to its pre-flatten state, then delete the backup so nothing is left behind. Choose the store with agent ("claude" default, or "codex"). Under codex a UUID reaches any rollout in the tree; "last"/"current" are scoped to the project dir ("current" falls back to "last").
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent | No | Which agent's session store to target: "claude" (default) or "codex". | claude |
| claude_dir | No | Absolute path (or ~/...) to the Claude config dir whose sessions to target — the dir holding projects/, e.g. ~/.claude-2 for a second profile. Default: $CLAUDE_CONFIG_DIR if set, else ~/.claude. Applies to agent "claude" only. | |
| codex_home | No | Absolute path (or ~/...) to the Codex home whose sessions to target — the dir holding sessions/. Default: $CODEX_HOME if set, else ~/.codex. Applies to agent "codex" only. | |
| session_id | Yes | Session UUID, "last", or "current" (the live session; under codex "current" falls back to "last") | |
| project_dir | No | Absolute path to project. Default: the project the CLI runs in (cwd). Under codex, scopes "last"/keyword to rollouts whose cwd equals this dir. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| newSize | Yes | Session file size after restoring, in bytes. | |
| skipped | No | Present with a reason when the restore was skipped (e.g. no backup to restore from). | |
| notFound | Yes | Marker ids that had no matching backup entry and were left in place. | |
| sessionId | Yes | The session UUID that was processed ("" when nothing matched). | |
| backupPath | Yes | The backup that was restored from (and removed on a full restore). | |
| originalSize | Yes | Session file size before restoring, in bytes. | |
| restoredCount | Yes | How many flattened tool results were re-inlined. |