Skip to content

[dotnet-port-fixes] Disengage history storage for service-managed sessions #884

Description

@github-actions

Summary

Align the Go agent runtime with microsoft/agent-framework#7284 by stopping history-provider persistence once a run is promoted to a service-managed session. The change keeps configured history providers attached for future local sessions, but skips storing the conflicting run when the provider service returns a session/service ID.

Ported .NET PRs

Breaking Changes

No. This changes internal history persistence behavior under the existing API so service-managed sessions no longer duplicate history into configured local providers.

Tests and Examples

  • go test ./agent ./provider/aguiprovider
  • Updated the agent history conflict regression test to verify the configured provider reference is preserved while the service-managed run is not stored locally

Notes

Skipped the later AGUI-specific follow-up in microsoft/agent-framework#7741 to keep this PR limited to the narrow parity fix from #7284. The chat-history comparison doc already reflects this area as partial, so no doc status change was needed.

Generated by .NET to Go Fixes and Test Porting Agent · gpt54 · 174.4 AIC · ⌖ 14 AIC · ⊞ 24.4K ·


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-port-fixes/history-provider-disengage-f8a0987865203085.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (80 of 80 lines)
From 8219941797d3106bb92cad3db9da1c5649aec2f3 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Fri, 21 Aug 2026 03:03:55 +0000
Subject: [PATCH] [dotnet-port-fixes] Disengage history storage for
 service-managed sessions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/agent.go      | 14 ++++++++++----
 agent/agent_test.go | 10 +++++-----
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/agent/agent.go b/agent/agent.go
index 10c512f5f..2203e1206 100644
--- a/agent/agent.go
+++ b/agent/agent.go
@@ -486,17 +486,23 @@ func (a *Agent) shouldStoreHistoryProvider(provider HistoryProvider, session *Se
 	if provider == nil {
 		return false
 	}
-	if !a.hasDefaultHistoryProvider {
-		return true
-	}
 	if a.providerDoesNotManageHistory {
 		// Provider never uses server-side history; always persist locally.
 		return true
 	}
+	if session != nil && session.ServiceID() != "" {
+		// Once the provider service owns the conversation history, no history
+		// provider should persist the run locally, even if a configured provider
+		// remains attached for future local sessions.
+		return false
+	}
+	if !a.hasDefaultHistoryProvider {
+		return true
+	}
 
 	// A provider can promote a local session to a service-managed one during the
 	// run. Once that happens, the default in-memory provider should stop storing.
-	return session != nil && session.ServiceID() == ""
+	return session != nil
 }
 
 func (a *Agent) handleHistoryProviderConflict(ctx context.Context, provider HistoryProvider, session *Session) (bool, error) {
diff --git a/agent/agent_test.go b/agent/agent_test.go
index 3c2576ff8..df5260907 100644
--- a/agent/agent_test.go
+++ b/agent/agent_test.go
@@ -1538,7 +1538,7 @@ func TestAgent_Run_HistoryProvider_ClearsWhenThrowDisabledAndClearEnabled(t *tes
 	}
 }
 
-func TestAgent_Run_HistoryProvider_KeepsWhenThrowAndClearDisabled(t *testing.T) {
+func TestAgent_Run_HistoryProvid
... (truncated)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions