anthropics / anthropics/claude-agent-sdk-python
SessionStore summary fast path paginates before filtering and can skip sessions
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 1.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
### Summary
`list_sessions_from_store()` can return a short page and skip valid sessions because its summary fast path applies offset/limit before placeholder sessions are loaded and filtered.
### Affected code
`src/claude_agent_sdk/_internal/sessions.py:1632-1715`
### Current behavior
Fresh summary rows are filtered before pagination. Sessions with missing or stale summary sidecars become placeholders. The code then:
1. Sorts all slots.
2. Applies `offset` and `limit`.
3. Loads only placeholders in that page.
4. Drops placeholders that resolve to sidechain/no-summary sessions.
5. Returns the remaining items without backfilling from later slots.
The source comment at lines 1708-1714 explicitly notes that this can short-page.
### Why this matters
The public API promises results sorted by `last_modified` with normal offset/limit semantics. The disk path and slow store path filter before pagination, while the fast path behaves differently based on sidecar freshness.
A UI requesting `limit=10` may receive fewer than ten items even when later valid sessions exist. Offset-based pagination can then skip those sessions permanently or produce inconsistent pages as sidecars become fresh.
### Suggested reproduction
Create a store where:
- the newest listed session lacks a sidecar and loads as a sidechain,
- several older sessions are valid,
- `limit=2`.
The fast path includes the placeholder in the two-slot page, drops it after loading, and returns one result instead of backfilling the next valid session.
### Expected behavior
Filtering semantics should be identical across disk, slow-store, and summary-fast paths.
### Possible fix
Iteratively load bounded batches of unresolved slots until enough valid results exist to satisfy `offset + limit`, or the candidate list is exhausted. The implementation can retain bounded concurrency and avoid loading all sessions eagerly.
Tests should cover missing and stale sidecars that resolve to sidechain and no-summary entries across multiple pages.
### Environment
- Repository revision: current `main` audit at SDK version 0.2.128
- Bundled CLI version: 2.1.220
- Python test suite: 1,291 passed, 5 skipped
- Ruff and mypy: clean
I searched the existing issues and pull requests using the affected symbols and behavior before filing this.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.