anthropics / anthropics/claude-agent-sdk-python

SessionStore summary fast path paginates before filtering and can skip sessions

オープン
#1,163 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
8.1k
フォーク
1.3k
PR マージ指標
PR 指標を取得中

説明

### 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。