Skip to content

Conversation

@eloramirez1356
Copy link

@eloramirez1356 eloramirez1356 commented Dec 11, 2025

Currently, querying events from a specific model instance via:

/experimental/events/model/{modelStreamId}

returns events ordered lexicographically by event ID, not by creation time. This behavior makes it difficult to fetch only the most recent events. For example, using resumeOffset does not reliably return the latest events because the last item in the response may not be the newest chronologically.

In a test scenario with 20 events, generating a 21st event resulted in it being inserted in the middle of the response. If an offset of 20 had been used, it would not have returned the most recent event (following image):
image

Proposed change:

  • Modify the API to return events sorted by creation timestamp rather than lexicographically by event ID.
  • This ensures that fetching events in chronological order is straightforward and resumeOffset works as expected.

Benefits:

  • Clients can reliably fetch the latest events without additional sorting.
  • Improves usability and correctness of event queries for model instances.

This image shows the result of the changes, where using offset 3 is properly used returning only future events:
image

This PR would fix the following error:
#751

@eloramirez1356 eloramirez1356 requested a review from a team as a code owner December 11, 2025 19:37
@eloramirez1356 eloramirez1356 requested review from smrz2001 and removed request for a team December 11, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant