[agentserver-responses] Keep newest history item IDs when applying limit - #48560
[agentserver-responses] Keep newest history item IDs when applying limit#48560Hashim Khan (Hashim1999164) wants to merge 2 commits into
Conversation
get_history_item_ids in the in-memory and file response stores used resolved[:limit], which dropped recent turns. Slice from the end so conversation history keeps the newest N items. Fixes Azure#48514.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 7 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution Hashim Khan (@Hashim1999164)! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
Updates history truncation to retain the newest items.
Changes:
- Uses tail slicing in memory and file stores.
- Strengthens the in-memory limit test.
- Adds a changelog entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
_memory.py |
Keeps newest in-memory history IDs. |
_file.py |
Keeps newest file-backed history IDs. |
test_in_memory_provider_crud.py |
Verifies newest IDs are retained. |
CHANGELOG.md |
Documents the bug fix. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| 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"] |
|
|
||
| ### Bugs Fixed | ||
|
|
||
| - Fixed `InMemoryResponseProvider` and `FileResponseProvider` `get_history_item_ids` |
[Pilot] PR Pipeline Failure AnalysisA CI pipeline failed on this pull request. Here is an automated analysis of what went wrong and how to get the build green. What failedTwo distinct failure types were detected in build 6694991:
Recommended next steps
Raw pipeline analysis (azsdk ci analyze)
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md:7
- The PR description says this fix belongs to
2.1.0b2 (Unreleased), but this instead changes the existing2.1.0b1release date and attributes the fix to that release. Add a new unreleased section and preserve the prior2.1.0b1 (2026-08-11)heading so users can identify which package version contains the fix.
## 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)
Summary
InMemoryResponseProvider.get_history_item_idsandFileResponseProvider.get_history_item_idstruncated withresolved[:limit], which kept the oldest IDs and dropped recent turns. Conversation history should keep the newest N items.This changes both providers to
resolved[-limit:]and tightens the unit test to assert the newest IDs are retained.Fixes #48514
Changelog
Updated
sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.mdunder2.1.0b2 (Unreleased).Test plan
pytest sdk/agentserver/azure-ai-agentserver-responses/tests/unit/test_in_memory_provider_crud.py::test_history__respects_limit