Skip to content

fix(acp): paginate list_sessions with cursor/next_cursor#13521

Merged
teknium1 merged 2 commits intomainfrom
hermes/hermes-3c64b440
Apr 21, 2026
Merged

fix(acp): paginate list_sessions with cursor/next_cursor#13521
teknium1 merged 2 commits intomainfrom
hermes/hermes-3c64b440

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Salvage of #13460 by @aniruddhaadak80closes #13450.

Summary

ACP list_sessions now respects cursor and returns next_cursor when more results remain. The page cap is a named module constant; cwd filtering (which already existed) is unchanged.

Changes

  • acp_adapter/server.py: cursor-based pagination, _LIST_SESSIONS_PAGE_SIZE = 50 module constant, docstring explaining cwd/cursor semantics. 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

  • Replaced kwargs.get('limit', 50) with the module constant. ListSessionsRequest has no limit field in the ACP schema, so the kwarg path was dead.
  • Switched nextCursor= kwarg to the declared field name next_cursor= (the schema sets populate_by_name=True, so both work; field name is consistent with the rest of the file).

Validation

Before After
list_sessions(cursor=...) Cursor ignored, full list returned Page resumes after cursor
ListSessionsResponse.next_cursor Always None Set to last session_id when more remain
60 sessions, 2 cwds page1=50 + next_cursor, page2=10, cwd filter=30, unknown cursor=[]
Tests 2 list_sessions tests 6 (all passing via scripts/run_tests.sh)

aniruddhaadak80 and others added 2 commits April 21, 2026 05:57
- 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.
@teknium1 teknium1 merged commit 4cc5065 into main Apr 21, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-3c64b440 branch April 21, 2026 13:00
@alt-glitch alt-glitch added type/bug Something isn't working comp/acp Agent Communication Protocol adapter labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/acp Agent Communication Protocol adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP list_sessions ignores cursor/cwd and never returns nextCursor

3 participants