Skip to content

[agentserver-responses] Keep newest history item IDs when applying limit - #48560

Open
Hashim Khan (Hashim1999164) wants to merge 2 commits into
Azure:mainfrom
Hashim1999164:fix/history-item-ids-keep-newest-48514
Open

[agentserver-responses] Keep newest history item IDs when applying limit#48560
Hashim Khan (Hashim1999164) wants to merge 2 commits into
Azure:mainfrom
Hashim1999164:fix/history-item-ids-keep-newest-48514

Conversation

@Hashim1999164

@Hashim1999164 Hashim Khan (Hashim1999164) commented Aug 12, 2026

Copy link
Copy Markdown

Summary

InMemoryResponseProvider.get_history_item_ids and FileResponseProvider.get_history_item_ids truncated with resolved[: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.md under 2.1.0b2 (Unreleased).

Test plan

  1. pytest sdk/agentserver/azure-ai-agentserver-responses/tests/unit/test_in_memory_provider_crud.py::test_history__respects_limit
  2. Confirm truncated results are the last N chronological IDs

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

Copy link
Copy Markdown
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.

@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/* labels Aug 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution Hashim Khan (@Hashim1999164)! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`
@github-actions

Copy link
Copy Markdown
Contributor
[Pilot] PR Pipeline Failure Analysis

A CI pipeline failed on this pull request. Here is an automated analysis of what went wrong and how to get the build green.

What failed

Two distinct failure types were detected in build 6694991:

  1. Test failure (all platforms): tests.unit.test_file_response_store_parity.test_history_respects_limit failed on every tested platform (macOS 3.11, Windows 3.12, Ubuntu 3.10/3.12/3.13/3.14). This is a consistent cross-platform failure pointing to a code issue in the test or the functionality under test.

  2. Validation failure (Build Analyze): The changelog for sdk/agentserver/azure-ai-agentserver-responses (version 2.1.0b1) has two issues:

    • The release date 2026-08-11 is not the latest date in the changelog file.
    • The changelog entry has an empty Bugs Fixed section — it must either have content or be removed.

Recommended next steps

  • Fix the failing test: Investigate tests.unit.test_file_response_store_parity.test_history_respects_limit — the test fails consistently across all OS/Python combinations, suggesting a logic bug in the test_history_respects_limit test case or in the history-limit behavior it exercises.
  • Fix the changelog: In sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md:
    • Ensure the 2.1.0b1 entry date (2026-08-11) is the most recent date in the file (or update it to today's date if this is the newest release).
    • Remove the empty Bugs Fixed section or add content to it.
  • See the CI troubleshooting guide: https://aka.ms/ci-fix
  • Push new commits to address the failures; this comment updates automatically on the next failing run.
Raw pipeline analysis (azsdk ci analyze)
Analyzing pipeline https://github.com/Azure/azure-sdk-for-python/pull/48560...
Getting failed workflow runs for commit 1f130cb921aa3d34b7eece822dbe3de7b617e01a in Azure/azure-sdk-for-python
Build: 6694991 Project: public PipelineUrl: https://dev.azure.com/azure-sdk/public/_build/results?buildId=6694991
--------------------------------------------------------------------------------
Failed Tests
--------------------------------------------------------------------------------
{
  "macos311": [
    "tests.unit.test_file_response_store_parity.test_history_respects_limit",
    "tests.unit.test_file_response_store_parity.test_history_respects_limit"
  ],
  "windows2022_312": [
    "tests.unit.test_file_response_store_parity.test_history_respects_limit",
    "tests.unit.test_file_response_store_parity.test_history_respects_limit"
  ],
  "Ubuntu2404_313": [
    "tests.unit.test_file_response_store_parity.test_history_respects_limit",
    "tests.unit.test_file_response_store_parity.test_history_respects_limit"
  ],
  "ubuntu2404_310_coverage": [
    "tests.unit.test_file_response_store_parity.test_history_respects_limit",
    "tests.unit.test_file_response_store_parity.test_history_respects_limit"
  ],
  "Ubuntu2404_314": [
    "tests.unit.test_file_response_store_parity.test_history_respects_limit",
    "tests.unit.test_file_response_store_parity.test_history_respects_limit"
  ],
  "ubuntu2404_312": [
    "tests.unit.test_file_response_store_parity.test_history_respects_limit",
    "tests.unit.test_file_response_store_parity.test_history_respects_limit"
  ]
}
--------------------------------------------------------------------------------
Failed Tasks
--------------------------------------------------------------------------------
### Errors:
--> /tmp/log-analysis-0ab9bd29681d49bfa4423e2feb12513d.txt:123
##[error]Invalid date [ 2026-08-11 ]. The date for the changelog being released must be the latest in the file.
##[error]The changelog entry has the following sections with no content (Bugs Fixed). Please ensure to either remove the empty sections or add content to the section.
##[error]PowerShell exited with code '1'.

### Pipeline: https://dev.azure.com/azure-sdk/public/_build/results?buildId=6694991

Copilot detected the failing pipeline and generated the analysis above. To have it attempt a fix automatically, reply with @copilot please fix the failing pipeline on this PR.

Generated by Pipeline Analysis - Next Steps · 21.1 AIC · ⌖ 8.97 AIC · ⊞ 6.6K ·

Copilot AI review requested due to automatic review settings August 13, 2026 00:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 existing 2.1.0b1 release date and attributes the fix to that release. Add a new unreleased section and preserve the prior 2.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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[azure-ai-agentserver-responses] get_history_item_ids uses resolved[:limit] — truncates newest history instead of oldest

2 participants