fix(acp): paginate list_sessions with cursor/next_cursor#13521
Merged
fix(acp): paginate list_sessions with cursor/next_cursor#13521
Conversation
- Replace kwargs.get('limit', 50) with module-level _LIST_SESSIONS_PAGE_SIZE
constant. ListSessionsRequest schema has no 'limit' field, so the kwarg
path was dead. Constant is the single source of truth for the page cap.
- Use next_cursor= (field name) instead of nextCursor= (alias). Both work
under the schema's populate_by_name config, but using the declared
Python field name is the consistent style in this file.
- Add docstring explaining cwd pass-through and cursor semantics.
- Add 4 tests: first-page with next_cursor, single-page no next_cursor,
cursor resumes after match, unknown cursor returns empty page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #13460 by @aniruddhaadak80 — closes #13450.
Summary
ACP
list_sessionsnow respectscursorand returnsnext_cursorwhen more results remain. The page cap is a named module constant;cwdfiltering (which already existed) is unchanged.Changes
acp_adapter/server.py: cursor-based pagination,_LIST_SESSIONS_PAGE_SIZE = 50module constant, docstring explainingcwd/cursorsemantics. Unknown cursor returns an empty page (no fallback to full list).tests/acp/test_server.py: 4 new tests — first-page w/ next_cursor, single-page no next_cursor, cursor resumes after match, unknown cursor returns empty.Follow-ups on top of #13460
kwargs.get('limit', 50)with the module constant.ListSessionsRequesthas nolimitfield in the ACP schema, so the kwarg path was dead.nextCursor=kwarg to the declared field namenext_cursor=(the schema setspopulate_by_name=True, so both work; field name is consistent with the rest of the file).Validation
list_sessions(cursor=...)ListSessionsResponse.next_cursorNonesession_idwhen more remainlist_sessionstestsscripts/run_tests.sh)