Skip to content

[FEATURE]: Add last chat message timestamp to GET /api/session #62655

Open

Description

@dluc

Request

Could GET /api/session optionally return the timestamp of each session’s most recent user or assistant chat message? It should be null if there are no chat messages.

What is available today

The session list already returns time.updated, but that can be more recent than the last chat message. For example, a session whose last message was three days ago can have an update time from six minutes ago. An app sorting conversations by time.updated would show that old conversation as recent.

Why this matters

A separate desktop app needing to list conversations from several OpenCode servers needs to show the most recent ones first. To get those timestamps today, the app must fetch messages separately for every session. These extra requests affect performance and return message content even though the app only needs timestamps.

For a hypothetical setup with three servers and 50 sessions each, assuming one session-list page per server:

  • Today: 3 list requests plus at least 150 message requests.
  • With the timestamp in the session list: 3 list requests.

The new timestamp would remain separate from time.updated; opening or renaming a session should not make its last chat message appear newer.

Related: #21078 requested a similar timestamp for CLI output and was closed for inactivity.

Activity

  1. opencodejr commented on Nov 7, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up, @dluc! You're asking for GET /api/session to optionally include, for each session, the timestamp of its most recent user or assistant message (null if there are none). It would be kept separate from time.updated, so clients can sort conversations by real chat activity without fetching every session's messages.

    The maintainers will consider it. This can't be built as a plugin today, because plugins can't add fields to the server's session list response.

    Related issues:

  2. dluc commented on Nov 7, 2026

    @dluc
    Author

    I'm exploring adding these timestamps to the existing session response:

    time.lastUserMessage?: number | null
    time.lastAssistantMessage?: number | null

    They would be returned by default, with null when no matching message exists. Existing fields would remain unchanged, and compatibility with existing clients would be checked.

    Would it be acceptable to add them directly to time, or should they initially go under experimental.time to follow the experimental API guidelines?

    lastAssistantMessage would refer to an assistant message, which can include a tool-only step. The rules for identifying a visible conversation message can be defined separately.

  3. dluc commented on Nov 8, 2026

    @dluc
    Author

    A related issue is that the session list is currently ordered and paginated by time.updated. Metadata changes such as renaming a session or changing its model can move it ahead of sessions with more recent conversation activity.

    Returning message timestamps lets clients display them without fetching every session's messages, but sorting only a fetched page by those timestamps can miss more recently active conversations outside that page. I think session-list ordering and pagination should eventually support ordering by conversation activity too. An explicit sort option could preserve the existing behavior for clients that rely on it.

    The timestamp addition I'm exploring leaves the current ordering unchanged. A follow-up would need to define which messages count as conversation activity, how to order sessions with no messages, and the cost of sorting before pagination. Also, activity-based cursor pagination can still shift when new messages arrive; it would not be a fixed snapshot.

    Would maintainers be open to considering that as a separate follow-up?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions