You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Add last chat message timestamp to GET /api/session #62655
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.
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.
I'm exploring adding these timestamps to the existing session response:
time.lastUserMessage?: number |nulltime.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.
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?
Activity
opencodejr commentedon Nov 7, 2026
Thanks for the detailed write-up, @dluc! You're asking for
GET /api/sessionto optionally include, for each session, the timestamp of its most recent user or assistant message (nullif there are none). It would be kept separate fromtime.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:
opencode session list --format jsonoutput #21078: the same timestamp, requested foropencode session list --format json(closed for inactivity)time.updated, which also makestime.updatedunreliable for ordering/sessionsproblem involving recent-activity time vs. creation timedluc commentedon Nov 7, 2026
I'm exploring adding these timestamps to the existing session response:
They would be returned by default, with
nullwhen 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 underexperimental.timeto follow the experimental API guidelines?lastAssistantMessagewould refer to an assistant message, which can include a tool-only step. The rules for identifying a visible conversation message can be defined separately.dluc commentedon Nov 8, 2026
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?