Add durable chat history ownership and session persistence - #95
Draft
Tamir Dresher (tamirdresher) wants to merge 11 commits into
Conversation
Define a draft language-neutral execution/completion contract, synthetic review fixtures, and explicit cross-runtime rollout prerequisites without activating runtime writes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Record independent gpt-5.6-sol ACCEPT of the unchanged schema-only tree 9051274. Keep the proposal commit unchanged and record both required trailers together in an append-only review record. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Constrain v2 correlations, preserve supported JSON message and structured result shapes, make the provisional binding optional, and clarify legacy ingestion and entity-local commit semantics. Add language-neutral validation cases without runtime activation. Binding representation and expired lookup outcome remain pending agreement. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Tamir Dresher (tamirdresher)
added this pull request to stack #96
September 11, 2026 19:24
Restore historical message and content validation, isolate expanded v2 transcript and terminal response definitions, and add full-envelope version boundary cases. Treat historyBinding as an opaque runtime profile and clarify authoritative expired outcomes without inventing legacy outcomes. No runtime activation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 532fe4f5-939b-4962-989d-a1883dccd283
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tamir Dresher (tamirdresher)
force-pushed
the
tamirdresher-microsoft-stack-3-history-provider
branch
from
September 12, 2026 03:09
4a0f438 to
d3872e1
Compare
Copilot started reviewing on behalf of
Tamir Dresher (tamirdresher)
September 12, 2026 03:10
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved moderate findings affect history replay and provider-key validation; required changelog entries are also missing.
Get a fresh assessment by requesting another Copilot review.
Review tier: Lite
Findings: 2
Open findings (2)
What changed in this PR
Adds C# durable history ownership, session persistence, replay filtering, and schema 2 mailbox integration.
Changes:
- Adds ownership bindings, provider-key handling, and compaction checks.
- Persists opaque sessions and stages durable history per operation.
- Integrates filtered replay, mailbox state, and related tests.
| File | Reviewed changes and notes |
|---|---|
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/EntityAgentWrapperTests.cs |
Tests wrapper identity and provider overrides. |
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/DurableChatHistoryProviderTests.cs |
Tests durable history staging and replay. |
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/DurableAgentSessionStateTests.cs |
Tests session persistence and restoration. |
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/DurableAgentHistoryOwnershipTests.cs |
Tests ownership resolution and validation. |
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/AgentEntityHistoryTests.cs |
Tests entity history integration. |
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/AgentEntityDeliveryTests.cs |
Tests mailbox and binding behavior. |
dotnet/src/Microsoft.Agents.AI.DurableTask/State/DurableAgentStateResponse.cs |
Adds lossless response conversion. |
dotnet/src/Microsoft.Agents.AI.DurableTask/State/DurableAgentStateRequest.cs |
Supports staged request conversion. |
dotnet/src/Microsoft.Agents.AI.DurableTask/State/DurableAgentStateReplay.cs |
Provides filtered replay projection. |
dotnet/src/Microsoft.Agents.AI.DurableTask/State/DurableAgentStateMessage.cs |
Supports replayable message conversion. |
dotnet/src/Microsoft.Agents.AI.DurableTask/README.md |
Documents ownership and mailbox behavior. |
dotnet/src/Microsoft.Agents.AI.DurableTask/Logs.cs |
Updates durable execution logging. |
dotnet/src/Microsoft.Agents.AI.DurableTask/EntityAgentWrapper.cs |
Applies operation-scoped provider integration. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableChatHistoryProvider.cs |
Stages entity-owned history. Moderate: merged context messages can duplicate prior transcript entries. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentsOptions.cs |
Adds ownership configuration. Nit: required changelog entry is missing. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentSessionState.cs |
Serializes and restores sessions. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentHistoryReplayMode.cs |
Defines replay policies. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentHistoryOwnershipNotSupportedException.cs |
Reports unsupported ownership. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentHistoryOwnership.cs |
Resolves ownership and compaction support. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentHistoryBindingMismatchException.cs |
Reports binding mismatches. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentHistoryBinding.cs |
Parses and seals bindings. Moderate: malformed provider keys can be adopted without validation. |
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentCompactionNotSupportedException.cs |
Reports unsupported compaction. |
dotnet/src/Microsoft.Agents.AI.DurableTask/AgentEntity.cs |
Integrates replay, sessions, ownership, and commits. Moderate: legacy promotion can duplicate and replay the transcript. Nit: required changelog entry is missing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+605
to
+611
| if (isLegacyState) | ||
| { | ||
| return workingState.Data.ConversationHistory | ||
| .SelectMany(entry => entry.Messages) | ||
| .Select(message => message.ToChatMessage()); | ||
| } | ||
|
|
Comment on lines
+62
to
+66
| this._history.Add(DurableAgentStateRequest.FromRunRequest( | ||
| this._request, | ||
| context.RequestMessages, | ||
| allowLosslessV2, | ||
| this._logger)); |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add the C# durable history-provider and opaque-session integration on top of the schema 2 mailbox and workflow-output trust-boundary foundation.
What changed
historyBindingoptional and provisional.C# fixed-owner profile
The shared
historyBindingshape from #92 is configuration metadata, not a cross-runtime effective-owner contract. The C# runtime adds an extension marker when it seals a binding after the first successful turn. Only marked C# bindings are treated as immutable runtime ownership.The logical provider key must remain stable across recreated provider/agent instances and must not be derived from CLR type names, credentials, process instances, or guessed
StateBagkeys.Legacy non-entity adoption requires owner-specific public evidence:
StateKeys;CurrentRequestOnlyand legacy per-service-call state cannot prove prior ownership and require a new durable session.No external transcript mirror
External-provider, service, and opaque agent-session owners append no new request or response messages to
conversationHistory. They still retain:Mailbox results are never reconstructed into provider history or replayed to the model.
Trust and failure boundaries
Compaction boundary
Directly discoverable
CompactionProviderconfigurations and in-memory reducers are rejected before execution.The pinned Agent Framework public API cannot universally inspect builder-installed or privately nested decorators. Hidden stateful-compaction pipelines are unsupported but cannot be reliably rejected before side effects without an upstream public capability hook. This implementation does not use private reflection, type-name scanning, guessed session keys, factory double invocation, or blanket state stripping.
Tests
Microsoft.Agents.AI.DurableTask.UnitTeststests in Release.Microsoft.Agents.AI.Hosting.AzureFunctions.UnitTeststests in Release.git diff --check.gpt-5.6-solformal review: ACCEPTED.Stack dependency
This is product stack layer 3 of 4.
tamirdresher-microsoft-harden-durable-delivery-ttl6f515fd70cc9372804245669d89735e8beaf6c37d3872e1e122b1462628793e193eb7409761b47281a84c82bNot in this PR
FollowCompactionReview reading order
DurableAgentHistoryBinding.csDurableAgentHistoryOwnership.csState/DurableAgentStateReplay.csandDurableChatHistoryProvider.csDurableAgentSessionState.csEntityAgentWrapper.csDurableAgentsOptions.csAgentEntity.csRelationship to prior drafts
This supersedes the obsolete layer-3 drafts based on
f4ce89eand2d5aa78. It preserves the accepted C# fixed-owner subset while integrating the final opaque optional history profile and the final layer-2 mailbox, consumer, TTL, rollback, versioned-envelope, and executor-output trust semantics.