Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Jul 24, 2025

We currently have it at the ChatResponse{Update} level, but for more agentic scenarios, it's helpful to have a timestamp per message.

Microsoft Reviewers: Open in CodeFlow

We currently have it at the ChatResponse{Update} level, but for more agentic scenarios, it's helpful to have a timestamp per message.
@stephentoub stephentoub requested a review from a team as a code owner July 24, 2025 22:18
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Jul 24, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a CreatedAt timestamp property to the ChatMessage class to support more granular timing information for individual messages, complementing the existing timestamp at the ChatResponse level.

Key changes:

  • Added DateTimeOffset? CreatedAt property to ChatMessage class
  • Updated message construction in OpenAI and Azure AI Inference clients to populate the timestamp
  • Modified response processing logic to handle per-message timestamps when converting between response formats

Reviewed Changes

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

Show a summary per file
File Description
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatMessage.cs Added CreatedAt property and updated clone method
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponse.cs Modified ToChatResponseUpdates to use message timestamp with fallback to response timestamp
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs Updated message processing to handle CreatedAt property during update consolidation
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs Set message CreatedAt from OpenAI completion timestamp
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Set message CreatedAt from OpenAI response timestamp
src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs Set message CreatedAt from Azure AI response timestamp
src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.json Added API surface entry for new property
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ChatCompletion/ChatMessageTests.cs Added tests for CreatedAt property roundtrip behavior
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ChatCompletion/ChatResponseTests.cs Updated and added tests for multi-message response conversion
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ChatCompletion/ChatResponseUpdateExtensionsTests.cs Added comprehensive test for message timestamp handling during update processing
Comments suppressed due to low confidence (1)

@stephentoub stephentoub merged commit 7798311 into dotnet:main Jul 25, 2025
7 checks passed
@stephentoub stephentoub deleted the messagecreatedat branch July 25, 2025 13:12
joakimia pushed a commit to heimdallpower/api-sdk that referenced this pull request Aug 21, 2025
Updated
[Microsoft.Extensions.Http.Resilience](https://github.com/dotnet/extensions)
from 9.7.0 to 9.8.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Extensions.Http.Resilience's
releases](https://github.com/dotnet/extensions/releases)._

## 9.8.0

## What's Changed
* Align EventId generation with M.E.Logging source-gen by @​xakep139 in
dotnet/extensions#6566
* Add resiliency mechanism to CPU and memory utilization checks by
@​amadeuszl in dotnet/extensions#6528
* Suppress flaky test until fixed by @​joelverhagen in
dotnet/extensions#6568
* Create a project template for an MCP server by @​joelverhagen in
dotnet/extensions#6547
* Use dnx instead of dotnet tool exec in MCP server template README by
@​joelverhagen in dotnet/extensions#6571
* Add reporting tests that show NLP results. by @​peterwald in
dotnet/extensions#6574
* Branding updates for 9.8.0 by @​joperezr in
dotnet/extensions#6573
* Fix `ConfigureEvaluationTests.ps1` script when `$ConfigRoot` is not
supplied by @​peterwald in
dotnet/extensions#6575
* Refactor Resource Monitoring by @​evgenyfedorov2 in
dotnet/extensions#6554
* Update McpServer template for 0.3.0-preview.2 by @​stephentoub in
dotnet/extensions#6578
* Add container.cpu.time metric by @​evgenyfedorov2 in
dotnet/extensions#5806
* Add netstandard2.0 compatibility to
Microsoft.Extensions.Diagnostics.Testing and dependencies by @​bdovaz in
dotnet/extensions#6219
* Add netstandard2.0 compatibility to Microsoft.Extensions.Telemetry and
dependencies by @​bdovaz in
dotnet/extensions#6218
* Simplify Http.Diagnostics by @​pentp in
dotnet/extensions#6174
* Add netstandard2.0 compatibility to
Microsoft.Extensions.Http.Resilience and dependencies by @​bdovaz in
dotnet/extensions#6582
* Ingore null loggers returned by LogProviders in ELoggerFactory by
@​petrroll in dotnet/extensions#6585
* Merging changes from internal by @​joperezr in
dotnet/extensions#6588
* [Logging] Fixes LogProperties and LogPropertyIgnore attributes to work
if an object being logged resides in a different assembly than the
logging method by @​iliar-turdushev in
dotnet/extensions#6600
* Add memory usage metric by @​evgenyfedorov2 in
dotnet/extensions#6586
* Add schema version to server.json in MCP template by @​joelverhagen in
dotnet/extensions#6606
* Merge release/9.7 into main by @​joperezr in
dotnet/extensions#6589
* Update MCP server template readme to show both VS Code and Visual
Studio notes by @​Copilot in
dotnet/extensions#6591
* Update Azure Open AI package referenced by eval integration tests by
@​shyamnamboodiripad in dotnet/extensions#6609
* Target .NET 8 for more stable runtime requirement by @​joelverhagen in
dotnet/extensions#6617
* Add support for new Azure AI Foundry project type for Safety evals by
@​shyamnamboodiripad in dotnet/extensions#6621
* M.E.AI.AzureAIInference - Azure.AI.Inference Package Bump by
@​rogerbarreto in dotnet/extensions#6624
* Add DataContent.Name property by @​stephentoub in
dotnet/extensions#6616
* Fix handling of multiple responses messages by @​stephentoub in
dotnet/extensions#6627
* Expose additional chat model conversion helpers by @​stephentoub in
dotnet/extensions#6629
* [main] Update dependencies from dotnet/arcade by @​dotnet-maestro[bot]
in dotnet/extensions#6633
* [Http.Resilience] The DisableFor method should try to retrieve the
request object from the resilience context by @​iliar-turdushev in
dotnet/extensions#6618
* Bump Package validation baseline version to 9.7.0 by @​Copilot in
dotnet/extensions#6650
* Fix internal package version detection for project templates by
@​MackinnonBuck in dotnet/extensions#6651
* Remove `Microsoft.Extensions.AI.Ollama` by @​MackinnonBuck in
dotnet/extensions#6655
* Fix M.E.AI package refs by @​stephentoub in
dotnet/extensions#6654
* Add [Description] to DataContent.Uri by @​stephentoub in
dotnet/extensions#6615
* Fix duplicate solution file when creating an AI Chat Web app from VS
by @​MackinnonBuck in dotnet/extensions#6653
* Add ChatMessage.CreatedAt by @​stephentoub in
dotnet/extensions#6657
* Add TextContent.Annotations by @​stephentoub in
dotnet/extensions#6619
* Add FunctionInvokingChatClient.AdditionalTools by @​stephentoub in
dotnet/extensions#6661
* Fix unintentional test env var change by @​stephentoub in
dotnet/extensions#6660
* Add more openai conversion helpers by @​stephentoub in
dotnet/extensions#6662
* Add OriginalRepoCommitHash to assemblies by @​BrennanConroy in
dotnet/extensions#6667
* Include a trivial items keyword if missing. by @​eiriktsarpalis in
dotnet/extensions#6669
* Add resolution of function parameter level data annotation attributes.
by @​eiriktsarpalis in dotnet/extensions#6671
* Fix issue with NetSourceIndexStage1 for dependency conflict versions
by @​joperezr in dotnet/extensions#6672
* Expose streaming conversion utility methods by @​stephentoub in
dotnet/extensions#6636
* Couple of fixes for MEAI.Evaluation by @​shyamnamboodiripad in
dotnet/extensions#6673
* Fix one more version conflict on the docs transport package by
@​joperezr in dotnet/extensions#6675
 ... (truncated)

## 9.7.2

## Packages Released

* [Microsoft.Extensions.AI.Templates
9.7.2-preview.3.25366.2](https://www.nuget.org/packages/Microsoft.Extensions.AI.Templates/9.7.2-preview.3.25366.2)

## What's Changed

* Target .NET 8 for more stable runtime requirement by @​joelverhagen in
#​6617

**Full Changelog**:
dotnet/extensions@v9.7.1...v9.7.2

## 9.7.1

## Packages Released

* [Microsoft.Extensions.AI
9.7.1](https://www.nuget.org/packages/Microsoft.Extensions.AI/9.7.1)
* [Microsoft.Extensions.AI.Abstractions
9.7.1](https://www.nuget.org/packages/Microsoft.Extensions.AI.Abstractions/9.7.1)
* [Microsoft.Extensions.AI.OpenAI
9.7.1-preview.1.25365.4](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI/9.7.1-preview.1.25365.4)
* [Microsoft.Extensions.AI.AzureAIInference
9.7.1-preview.1.25365.4](https://www.nuget.org/packages/Microsoft.Extensions.AI.AzureAIInference/9.7.1-preview.1.25365.4)
* [Microsoft.Extensions.AI.Templates
9.7.1-preview.3.25365.4](https://www.nuget.org/packages/Microsoft.Extensions.AI.Templates/9.7.1-preview.3.25365.4)

## What's Changed

* Merging changes from internal by @​joperezr in #​6588
* Bump FunctionInvokingChatClient.MaximumIterationsPerRequest from 10 to
40 by @​stephentoub in #​6599
* Expose M.E.AI.OpenAI input message conversions by @​stephentoub in
#​6601
* Add schema version to server.json in MCP template by @​joelverhagen in
#​6606
* Update MCP server template readme to show both VS Code and Visual
Studio notes by @​jeffhandley in #​6591
* Fix schema generation for Nullable<T> function parameters. by
@​eiriktsarpalis in #​6596
* Branding updates for 9.7.1 by @​joperezr in
dotnet/extensions#6611
* Add DelegatingAIFunction by @​stephentoub in
dotnet/extensions#6565
* Add FunctionInvokingChatClient.FunctionInvoker delegate by
@​stephentoub in dotnet/extensions#6564
* Enable specifying "strict" for OpenAI clients via ChatOptions by
@​stephentoub in dotnet/extensions#6552
* AIFunctionFactory: tolerate JSON string function parameters. by
@​eiriktsarpalis in dotnet/extensions#6572
* AIFunctionFactory: add test coverage for JSON comments. by
@​eiriktsarpalis in dotnet/extensions#6576
* Update M.E.AI.OpenAI for latest OpenAI release by @​stephentoub in
dotnet/extensions#6577
* Update OpenTelemetry semantic conventions version from 1.35 to 1.36 by
@​Copilot in dotnet/extensions#6579
* AIFunctionFactory: add a flag for disabling return schema generation.
by @​eiriktsarpalis in dotnet/extensions#6551
* Bump FunctionInvokingChatClient.MaximumIterationsPerRequest from 10 to
40 by @​stephentoub in dotnet/extensions#6599
* Expose M.E.AI.OpenAI input message conversions by @​stephentoub in
dotnet/extensions#6601
* Fix schema generation for Nullable<T> function parameters. by
@​eiriktsarpalis in dotnet/extensions#6596


**Full Changelog**:
dotnet/extensions@v9.7.0...v9.7.1

Commits viewable in [compare
view](dotnet/extensions@v9.7.0...v9.8.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.Extensions.Http.Resilience&package-manager=nuget&previous-version=9.7.0&new-version=9.8.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Aug 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants