Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release History

## 2.1.0b1 (2026-08-11)
## 2.1.0b1 (2026-08-13)

### Bugs Fixed

- `get_history_item_ids` on the in-memory and file stores now keeps the newest item IDs when applying `limit`. (#48514)

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ async def get_history_item_ids(

if limit <= 0:
return []
return resolved[:limit]
# Keep the most recent N history items (drop oldest when over limit).
return resolved[-limit:]

# ------------------------------------------------------------------
# Internal helpers (must be called with self._lock held)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ async def get_history_item_ids(

if limit <= 0:
return []
return resolved[:limit]
# Keep the most recent N history items (drop oldest when over limit).
return resolved[-limit:]

async def create_execution(self, execution: ResponseExecution, *, ttl_seconds: int | None = None) -> None:
"""Create a new execution and replay container for ``execution.response_id``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ async def test_history_respects_limit(tmp_path: Path) -> None:
history_item_ids=["hist1", "hist2"],
)
ids = await provider.get_history_item_ids("r_prev", None, limit=3)
assert ids == ["hist1", "hist2", "in1"]
# Chronological order is oldest-first; truncation must keep the newest IDs.
assert ids == ["out1", "out2", "out3"]
# Non-positive limit returns empty.
ids_zero = await provider.get_history_item_ids("r_prev", None, limit=0)
assert ids_zero == []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def test_history__respects_limit() -> None:

ids = asyncio.run(provider.get_history_item_ids("resp_lim", None, 3))
assert len(ids) == 3
# Chronological order is oldest-first; truncation must keep the newest IDs.
assert ids == ["in_lim_7", "in_lim_8", "in_lim_9"]


def test_history__zero_limit_returns_empty() -> None:
Expand Down