Skip to main content
Glama

Unflatten (restore) session

unflatten_session
Destructive

Restore 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

TableJSON Schema
NameRequiredDescriptionDefault
agentNoWhich agent's session store to target: "claude" (default) or "codex".claude
claude_dirNoAbsolute 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_homeNoAbsolute 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_idYesSession UUID, "last", or "current" (the live session; under codex "current" falls back to "last")
project_dirNoAbsolute 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

TableJSON Schema
NameRequiredDescriptionDefault
newSizeYesSession file size after restoring, in bytes.
skippedNoPresent with a reason when the restore was skipped (e.g. no backup to restore from).
notFoundYesMarker ids that had no matching backup entry and were left in place.
sessionIdYesThe session UUID that was processed ("" when nothing matched).
backupPathYesThe backup that was restored from (and removed on a full restore).
originalSizeYesSession file size before restoring, in bytes.
restoredCountYesHow many flattened tool results were re-inlined.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds behavioral details beyond annotations: it explicitly states the backup is deleted, which aligns with destructiveHint=true. It also explains per-agent behavior and keyword scoping, providing full transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, each carrying essential information: core action in the first, agent-specific nuances in the second. No redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, 1 required, output schema exists), the description covers all necessary aspects: purpose, behavioral details, parameter semantics, and agent-specific behavior. The output schema handles return values, so no gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, baseline is 3. The description adds meaning by explaining how 'agent' selects the store, how 'session_id' handles UUID/keywords, and how 'project_dir' scopes lookups for codex. This significantly aids correct invocation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool reverses a flatten operation by re-inlining tool results and deleting the backup. It distinguishes from siblings like flatten_session (the opposite) by specifying it restores the pre-flatten state.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use (restoring a flattened session) and provides context for agent and scope selection. It lacks explicit when-not-to-use or alternatives, but the sibling list and context make it clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shayaShav/flatten-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server