AHP listSessions ignores limit and cursor pagination parameters
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Summary
The VS Code AHP server accepts the paginated `listSessions` request shape, but ignores both `limit` and `cursor` and returns the complete session catalogue without a `nextCursor`.
I reproduced this through the local AHP endpoint:
```json
{ "channel": "ahp-root://", "limit": 5 }
```
The response contained 188 items.
### Code pointers
The protocol documents `listSessions` as incrementally pageable, including an example request with `limit` and a response with `nextCursor`:
- [`channels-root/commands.ts`](https://github.com/microsoft/vscode/blob/70ca5925227646d67c1d35e38ab1f89b4b3f6a98/src/vs/platform/agentHost/common/state/protocol/channels-root/commands.ts#L20-L66)
- [`PaginatedParams`](https://github.com/microsoft/vscode/blob/70ca5925227646d67c1d35e38ab1f89b4b3f6a98/src/vs/platform/agentHost/common/state/protocol/common/commands.ts#L44-L102)
The server handler discards the typed request params, calls the unpaged service, maps every session, and returns only `{ items }`:
- [`protocolServerHandler.ts`](https://github.com/microsoft/vscode/blob/70ca5925227646d67c1d35e38ab1f89b4b3f6a98/src/vs/platform/agentHost/node/protocolServerHandler.ts#L1403-L1428)
The existing handler tests cover field mapping, but every `listSessions` request omits pagination inputs; there is no limit/cursor coverage:
- [`protocolServerHandler.test.ts`](https://github.com/microsoft/vscode/blob/70ca5925227646d67c1d35e38ab1f89b4b3f6a98/src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts#L739-L853)
### Expected
- `limit: 5` returns at most five items.
- If more items exist, the result includes an opaque `nextCursor`.
- Passing that cursor returns the next page.
- Unknown cursors are rejected as invalid parameters, as documented.
- Pages are ordered most-recently-modified first.
At minimum, paging in `ProtocolServerHandler` would bound the wire response. To avoid enumerating the full provider catalogue as well, pagination would need to flow through `IAgentService.listSessions()` and its providers.
### Related
- #327021 describes the cost of repeatedly enumerating a large Copilot CLI session store. This issue is specifically about the AHP server ignoring its exposed pagination parameters.
- #327626 covers optional-field drift in the same `listSessions` mapping, not pagination.
Contributor guide
Assessment
This issue has not been assessed yet.