Skip to content

Feature: add session message count endpoint for efficient counting #14021

@sjawhar

Description

@sjawhar

Summary

Add a dedicated session message count API endpoint and backing session function so clients can retrieve message counts without streaming/deserializing full message history.

Problem

Counting messages currently requires loading all messages, which adds unnecessary overhead and latency when only the count is needed.

Proposed solution

  • Add a Session.messageCount() helper using SELECT COUNT(*)
  • Expose GET /session/:sessionID/message/count
  • Return a lightweight count payload with existing auth/validation/error patterns

Context

This issue is to track and link the existing implementation proposed in PR #13795.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)needs: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