Skip to content

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

Description

Bug Report

Package: azure-ai-agentserver-responses
Version: 1.0.0b9 (also present in b10)
Python: 3.14

Description

get_history_item_ids() in both InMemoryResponseProvider and FoundryResponseProvider
truncates history from the wrong direction. It uses resolved[:limit] which keeps the
oldest N items and drops the newest — the opposite of correct behavior for
conversation history.

Affected files

  • azure/ai/agentserver/responses/store/_memory.py
  • azure/ai/agentserver/responses/store/_foundry_provider.py (same pattern)

Expected behavior

resolved[-limit:] — keep the most recent N items, drop the oldest.

Actual behavior

resolved[:limit] — keeps the first N items (oldest), drops recent turns.

Impact

In multi-turn hosted agents (20+ turns), the agent loses visibility of recent
user messages, feedback, and decisions. It retains old context (initial setup)
but can't see what just happened — causing it to repeat steps or ignore recent
user input. The default default_fetch_history_count=100 makes this trigger
around turn 25-30 in tool-heavy workflows.

Workaround

Set ResponsesServerOptions(default_fetch_history_count=500) to delay the
truncation, but this doesn't fix the direction bug.

Suggested fix

# _memory.py , _foundry_provider.py equivalent
return resolved[-limit:]  # keep newest N, not oldest N

Suggested labels

bug, Hosted Agents, Client

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Hosted Agentssdk/agentserver/*Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions