Repository navigation
session_list tool only returns current session, not all historical sessions #14668
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't workingneeds:complianceThis means the issue will auto-close after 2 hours.This means the issue will auto-close after 2 hours.
Description
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
- Open OpenCode TUI
- Run /session command (or use session_list tool)
- Observe that only 1 session (current) is displayed
- 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds:complianceThis means the issue will auto-close after 2 hours.This means the issue will auto-close after 2 hours.
Activity
github-actions commentedon Feb 22, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
_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.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.
github-actions commentedon Feb 22, 2026
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.