Skip to content

opencode export returns "Session not found" for sessions with large part data (>1GB) #22072

Closed as not planned

Description

@jonnxpr

Description

The opencode export command fails with Error: Session not found: <session_id> for sessions whose part table data exceeds approximately 1GB, even though the sessions exist in the database and appear normally in opencode session list.
The error message is misleading — the session IS found during listing, but the export process crashes during JSON serialization of the session data, and the crash is caught and surfaced as a "not found" error.

Environment

  • OpenCode version: 1.4.3
  • OS: Windows 11 (10.0.26100), x64
  • Node.js: v24.14.1
  • System RAM: 32GB
  • Database size: 9.36GB (~/.local/share/opencode/opencode.db)
  • Total parts in DB: 152,977 entries, ~3.15GB of part data
Image

The threshold appears to be around 1GB of serialized part data. Sessions below this threshold export successfully.
Root Cause Analysis
I investigated the SQLite database directly using better-sqlite3:

  1. Sessions exist in the database — all failing session IDs are present in the session table with complete metadata (id, title, slug, timestamps, etc.)
  2. Messages and parts exist — the message and part tables contain all expected records with valid JSON data
  3. Database integrity is fine — PRAGMA integrity_check returns ok
  4. No archiving or soft-delete — time_archived is NULL for all sessions
    The export command is likely hitting a Node.js heap memory limit when it attempts to load and serialize 1+ GB of part data into a single JSON response. The OOM crash is caught and incorrectly reported as "Session not found".

Plugins

No response

OpenCode version

1.4.3

Steps to reproduce

  1. Have a session with large accumulated data (8,000+ messages with 38,000+ parts totaling >1GB in the part table)
  2. Run opencode session list — the session appears normally
  3. Run opencode export <session_id> — either via interactive selection or passing the ID directly
  4. Observe: Error: Session not found: <session_id>

Screenshot and/or share link

Image

Operating System

Windows 11 (10.0.26100), x64

Terminal

PowerShell 7.6.0

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Apr 11, 2026
  2. removed
    bugSomething isn't working
    perfIndicates a performance issue or need for optimization
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. blain3white commented on Jun 9, 2026

    @blain3white

    I'm the maintainer of Clean My Agent. This overlaps with its scope: scanning local Codex/Claude/Cursor/Gemini/OpenCode sessions and exporting Markdown/JSON/universal relay JSON, so it may be useful as a reference: https://github.com/blain3white/clean-my-agent

  4. github-actions commented on Aug 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions