You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode export returns "Session not found" for sessions with large part data (>1GB) #22072
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.
Total parts in DB: 152,977 entries, ~3.15GB of part data
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:
Sessions exist in the database — all failing session IDs are present in the session table with complete metadata (id, title, slug, timestamps, etc.)
Messages and parts exist — the message and part tables contain all expected records with valid JSON data
Database integrity is fine — PRAGMA integrity_check returns ok
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
Have a session with large accumulated data (8,000+ messages with 38,000+ parts totaling >1GB in the part table)
Run opencode session list — the session appears normally
Run opencode export <session_id> — either via interactive selection or passing the ID directly
Activity
blain3white commentedon Jun 9, 2026
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
github-actions commentedon Aug 9, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.