Skip to content

opencode session list shows too few sessions and --max-count is not honored #14163

Closed

Description

@mharris717

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

  1. Have a project with many sessions (including delegation/subagent sessions)
  2. Run opencode session list --format json | python3 -c "import sys,json; print(len(json.load(sys.stdin)))"
  3. Run opencode session list -n 1000 --format json | python3 -c "import sys,json; print(len(json.load(sys.stdin)))"
  4. Both return the same small number (~24), despite having far more root sessions in the DB
  5. 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

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions