FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

.NET: Add Cosmos chat history retrieval API by ilia-sokolov · Pull Request #7412 · microsoft/agent-framework · GitHub

Repository navigation

.NET: Add Cosmos chat history retrieval API - #7412

Merged
westey (westey-m) merged 8 commits into
microsoft:mainfrom
ilia-sokolov:contrib/3809-cosmos-get-messages
Aug 17, 2026
Merged

westey (westey-m) merged 8 commits into
microsoft:mainfrom
ilia-sokolov:contrib/3809-cosmos-get-messages

Conversation

Ilia Sokolov (ilia-sokolov) commented Jul 29, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Motivation & Context

CosmosChatHistoryProvider exposes utilities for counting and clearing stored messages, but applications cannot retrieve those messages without running the agent invocation pipeline. This makes migration, inspection, and other out-of-band conversation-history scenarios unnecessarily difficult.

Description & Review Guide

  • What are the major changes?
    • Add GetMessagesAsync(AgentSession?, CancellationToken) to retrieve the messages stored for a session.
    • Reuse that method from ProvideChatHistoryAsync so public and invocation retrieval share the same Cosmos query, pagination, MaxItemCount, and MaxMessagesToRetrieve behavior.
    • Document that direct retrieval returns raw stored messages without the invocation pipeline's output filter or chat-history source attribution.
    • Dispose the Cosmos feed iterator and add coverage for pagination, empty histories, filtering/source attribution, disposal, and cancellation.
  • What is the impact of these changes?
    • Consumers can inspect Cosmos-backed chat history without initiating an agent run.
    • Existing invocation behavior remains unchanged.
  • What do you want reviewers to focus on?
    • The session-aware API shape and the documented distinction between raw retrieval and invocation-processed messages.

Related Issue

Fixes #3809

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
    • The Cosmos emulator-dependent tests are added and compile successfully, but were skipped locally because the emulator is unavailable. They should run in the emulator-enabled CI environment.
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Adds a public retrieval API to the .NET Cosmos-backed chat history provider so callers can read stored conversation messages out-of-band (without running the agent invocation pipeline), while reusing the same Cosmos query/pagination logic that invocation retrieval uses.

Changes:

  • Added GetMessagesAsync(AgentSession?, CancellationToken) to CosmosChatHistoryProvider for direct message retrieval.
  • Refactored invocation history retrieval (ProvideChatHistoryAsync) to reuse GetMessagesAsync so both paths share the same query/paging/limits behavior.
  • Added Cosmos emulator-dependent unit tests covering pagination, empty histories, filter/source-attribution differences, disposal, and cancellation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs Introduces the new retrieval API and routes invocation history retrieval through it; disposes the Cosmos query iterator.
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs Adds emulator-based tests validating the new public retrieval behavior and its differences from invocation-processed history.

This branch was previously deployed

2 inactive deployments
github-app-auth — b663e4db Deployed Aug 16, 2026 by ilia-sokolov via add_label #20719
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Feature]: Add GetMessagesAsync method to CosmosChatHistoryProvider

4 participants


Back | FazBrowse Home | New Git URL