Skip to content

session_list tool only returns current session, not all historical sessions #14668

Closed as not planned

Description

@pengyu18119-maker

Description

Description
The session_list tool (accessed via /session command in TUI) only returns the currently active session instead of listing all available sessions. However, the underlying database contains all session data correctly, and session_search tool can find sessions properly.
Steps to Reproduce

  1. Open OpenCode TUI
  2. Run /session command (or use session_list tool)
  3. Observe that only 1 session (current) is displayed
  4. Verify database contains many sessions:
    python -c "
    import sqlite3
    conn = sqlite3.connect('~/.local/share/opencode/opencode.db')
    cursor = conn.cursor()
    cursor.execute('SELECT COUNT(*) FROM session WHERE parent_id IS NULL')
    print(f'Root sessions: {cursor.fetchone()[0]}')
    "

Expected Behavior
session_list should return all root sessions (sessions with parent_id IS NULL), ordered by time_updated DESC, optionally filtered by:

  • directory - filter by project directory
  • roots - only return root sessions
  • start - filter by timestamp
  • limit - maximum number to return
    Actual Behavior
    session_list only returns the currently active session, ignoring all historical sessions.
    Diagnostic Information
    Database Stats
    Total sessions: 1601
    Root sessions (parent_id IS NULL): 123
    Sessions with messages: 84 (in current directory)
    Total messages: 16479
    Database size: 109 MB
    Session API Parameters
    From SDK (@opencode-ai/sdk), the Session.list endpoint supports:
    {
    directory?: string; // Filter by project directory
    roots?: boolean; // Only return root sessions
    start?: number; // Filter by timestamp (ms since epoch)
    search?: string; // Filter by title (case-insensitive)
    limit?: number; // Max sessions to return
    }
    Workaround
    session_search tool works correctly and can find historical sessions:
    session_search query="any_keyword"
    Environment
  • OpenCode Version: 1.2.10
  • Platform: Windows 11
  • Database Path: C:\Users<user>.local\share\opencode\opencode.db
    Additional Context
    The database queries confirm data integrity:
    -- All root sessions exist
    SELECT COUNT(*) FROM session WHERE parent_id IS NULL;
    -- Result: 123
    -- Root sessions with messages
    SELECT COUNT(DISTINCT s.id)
    FROM session s
    JOIN message m ON s.id = m.session_id
    WHERE s.parent_id IS NULL;
    -- Result: 84
    -- Recent root sessions
    SELECT id, title, time_updated
    FROM session
    WHERE parent_id IS NULL
    ORDER BY time_updated DESC
    LIMIT 10;
    -- Returns valid data
    The issue appears to be in the session_list tool implementation, not the API or database layer.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Feb 22, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The required template fields (OpenCode version, Operating System, Terminal, Steps to reproduce) are all left as _No response_. While some of this information appears in the free-form description, please fill in the structured template fields so it's easier to triage.
    • The description reads as AI-generated (highly structured, includes database stats, SDK schema dumps, SQL queries). Please provide a more focused, personal account of the issue — what you observed, what you expected, and minimal steps to reproduce.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on Feb 22, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions