[PR #13795] feat(session): add messageCount endpoint for efficient message counting #14810

Open
opened 2026-02-16 18:19:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13795

State: open
Merged: No


Summary

  • Adds a Session.messageCount() function that uses SELECT COUNT(*) to efficiently get the number of messages in a session without loading all message data
  • Adds a GET /:sessionID/message/count API route exposing this function
  • Avoids the overhead of streaming and deserializing every message when only the count is needed

Changes

  • packages/opencode/src/session/index.ts: New messageCount export using Drizzle sql template for COUNT(*)
  • packages/opencode/src/server/routes/session.ts: New route with OpenAPI docs, param validation, and error responses
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13795 **State:** open **Merged:** No --- ## Summary - Adds a `Session.messageCount()` function that uses `SELECT COUNT(*)` to efficiently get the number of messages in a session without loading all message data - Adds a `GET /:sessionID/message/count` API route exposing this function - Avoids the overhead of streaming and deserializing every message when only the count is needed ## Changes - `packages/opencode/src/session/index.ts`: New `messageCount` export using Drizzle `sql` template for `COUNT(*)` - `packages/opencode/src/server/routes/session.ts`: New route with OpenAPI docs, param validation, and error responses
yindo added the pull-request label 2026-02-16 18:19:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14810