-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Description
Description
opencode session list only shows ~24 sessions despite having 500+ in the database (118 root sessions). The --max-count / -n flag has no effect for values above that ~24 count.
Root cause: The CLI handler calls Session.list() with no arguments, so the DB query applies a default LIMIT 100. Child/delegation sessions are then filtered out in JS (if (!session.parentID)), and --max-count is applied via Array.slice() after that. Since many of the 100 DB rows are child sessions, only ~24 root sessions survive — and -n 1000 can never return more.
The server HTTP API (/session) already handles this correctly by passing roots: true to the query, which adds WHERE parent_id IS NULL so the LIMIT applies only to root sessions.
Related: #13877 (same root cause affecting TUI /sessions picker)
Plugins
None
OpenCode version
1.2.6
Steps to reproduce
- Have a project with many sessions (including delegation/subagent sessions)
- Run
opencode session list --format json | python3 -c "import sys,json; print(len(json.load(sys.stdin)))" - Run
opencode session list -n 1000 --format json | python3 -c "import sys,json; print(len(json.load(sys.stdin)))" - Both return the same small number (~24), despite having far more root sessions in the DB
- Compare with:
opencode db "SELECT COUNT(*) FROM session WHERE parent_id IS NULL"
Screenshot and/or share link
No response
Operating System
macOS (darwin, arm64)
Terminal
Ghostty