Skip to content

feat(acp): paginate session list#9199

Open
kalvinnchau wants to merge 1 commit into
mainfrom
kalvin/acp-session-pagination
Open

feat(acp): paginate session list#9199
kalvinnchau wants to merge 1 commit into
mainfrom
kalvin/acp-session-pagination

Conversation

@kalvinnchau
Copy link
Copy Markdown
Collaborator

summary

implements acp pagination for session/list, per https://agentclientprotocol.com/protocol/session-list#pagination

  • uses a fixed backend page size of 50
  • returns nextCursor when more sessions are available
  • accepts cursor from the previous response
  • honors cwd as an exact absolute-path filter
  • rejects malformed cursors, relative cwd, and cursor/cwd mismatches with invalid_params

notes

this is a behavioral change for acp clients: session/list {} now returns the first page instead of every visible session.
clients must follow nextCursor to retrieve all sessions.

the cursor stores both updated_at and session_id because goose timestamps can collide at second precision. this avoids
skipping or duplicating sessions when multiple rows share the same timestamp.

add keyset pagination for acp session/list using a fixed server
page size and opaque cursors.

filter cwd and nonempty sessions before paging so nextcursor reflects
the visible result set.

Signed-off-by: Kalvin Chau <kalvin@block.xyz>
@kalvinnchau kalvinnchau force-pushed the kalvin/acp-session-pagination branch from e544d56 to fdfcffb Compare May 14, 2026 01:11
@DOsinga
Copy link
Copy Markdown
Collaborator

DOsinga commented May 15, 2026

thanks -- this PR is the right idea but I think we need to clean up a few things here before we merge:

list_nonempty_sessions_by_types_paged re-implements the column list, JOIN, GROUP BY, and bind logic of list_sessions_by_types. Refactor to one query function with optional filters/cursor/limit, otherwise this is going to be a continuous maintenance burden.

insert_session_for_list looks like a method that is only there for testing, but that in effect means we are testing what that method does, not what happens in the wild.

moving session/list from ? to respond_with_error is a behavior change for existing clients. Mention it in the PR description and cc @alexhancock to see if this breaks the existing TUI library.

I would also hash the filters into the cursor to make this more future proof when we want to add more to the filter -- like the session type.

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.

2 participants