Sessions

Every conversation and task in Opta is tracked as a session. Use the sessions command group to list, inspect, export, and manage your session history.

Overview

Sessions are the fundamental unit of interaction in Opta. Each opta chat or opta do invocation creates a new session (or resumes an existing one). Sessions persist all messages, tool calls, tool results, and metadata to disk so you can review, export, or continue them later.

Listing Sessions

opta sessions list shows all stored sessions, sorted by most recent first. Each entry displays the session ID, title (auto-generated from the first message), creation date, and message count.

List all sessions
opta sessions list
ID          Title                          Created           Messages
abc12345    Refactor auth module           2 hours ago       24
def67890    Add JWT validation             Yesterday         18
ghi11223    Fix TypeScript errors          3 days ago        12
jkl44556    Write API documentation        5 days ago        31

Viewing a Session

opta sessions show displays the full contents of a session, including all messages, tool calls, and results. Use this to review what happened in a previous conversation or task.

View a specific session
opta sessions show abc12345
View session with collapsed tool calls
opta sessions show abc12345 --compact

Exporting Sessions

opta sessions export writes a session to a file in JSON format. This is useful for sharing sessions, archiving important conversations, or processing session data with external tools.

Export a session to JSON
opta sessions export abc12345
Exported to ./opta-session-abc12345.json
Export to a specific path
opta sessions export abc12345 --output ~/exports/auth-refactor.json

Deleting Sessions

opta sessions delete permanently removes a session from disk. This action cannot be undone.

Delete a session
opta sessions delete abc12345
Session abc12345 deleted.
Permanent deletion
Deleting a session removes all messages, tool calls, and metadata permanently. There is no trash or undo. Export the session first if you may need it later.

Storage Location

Sessions are stored as JSON files in the daemon's configuration directory. Each session gets its own subdirectory containing the session data and any associated metadata.

Session storage structure
~/.config/opta/sessions/
├── abc12345/
│   ├── session.json        # Messages, tool calls, metadata
│   └── metadata.json       # Title, timestamps, stats
├── def67890/
│   ├── session.json
│   └── metadata.json
└── ...
Info
The session directory follows the XDG Base Directory specification. On macOS, this defaults to ~/.config/opta/sessions/. On Linux, it respects the XDG_CONFIG_HOME environment variable.

Session Format

Sessions are stored as JSON, following the daemon v3 protocol schema. Each session contains an array of events including user messages, assistant responses, tool calls, and tool results.

session.json
{
  "sessionId": "abc12345",
  "title": "Refactor auth module",
  "createdAt": "2026-03-01T10:30:00Z",
  "updatedAt": "2026-03-01T11:15:00Z",
  "events": [
    {
      "type": "user.message",
      "content": "Refactor the auth module to use JWT",
      "seq": 1
    },
    {
      "type": "assistant.message",
      "content": "I'll refactor the auth module...",
      "seq": 2
    },
    {
      "type": "tool.call",
      "toolName": "read_file",
      "args": { "path": "src/auth/index.ts" },
      "seq": 3
    }
  ]
}

Cross-Client Continuity

Sessions created in the CLI are accessible from any Opta client that connects to the same daemon. This means you can start a conversation in the CLI, then continue it in the Opta Local Web interface or the Opta Code Desktop app.

ClientRead SessionsCreate SessionsResume Sessions
Opta CLIYesYesYes
Opta Local WebYesYesYes
Opta Code DesktopYesYesYes
Resuming sessions
To resume a session from the CLI, pass the session ID to the chat command: opta chat --session abc12345. The conversation picks up exactly where you left off, with full context preserved.