diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.cs index e89888da9e..5d4e77474a 100644 --- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.cs +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.cs @@ -41,8 +41,8 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize return typedSession.Serialize(jsonSerializerOptions); } - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) - => new(new CustomAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + => new(new CustomAgentSession(serializedState, jsonSerializerOptions)); protected override async Task RunCoreAsync(IEnumerable messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs b/dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs index 30676a2336..3c4528a419 100644 --- a/dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs @@ -79,8 +79,8 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize } /// - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) - => new(new A2AAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + => new(new A2AAgentSession(serializedState, jsonSerializerOptions)); /// protected override async Task RunCoreAsync(IEnumerable messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs index 537df0fc8f..f2af2680f1 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs @@ -143,18 +143,18 @@ public abstract class AIAgent /// /// Deserializes an agent session from its JSON serialized representation. /// - /// A containing the serialized session state. + /// A containing the serialized session state. /// Optional settings to customize the deserialization process. /// The to monitor for cancellation requests. The default is . - /// A value task that represents the asynchronous operation. The task result contains a restored instance with the state from . - /// The is not in the expected format. + /// A value task that represents the asynchronous operation. The task result contains a restored instance with the state from . + /// The is not in the expected format. /// The serialized data is invalid or cannot be deserialized. /// /// This method enables restoration of conversation sessions from previously saved state, /// allowing conversations to resume across application restarts or be migrated between /// different agent instances. /// - public abstract ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default); + public abstract ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default); /// /// Run the agent with no message assuming that all required instructions are already provided to the agent or on the session. diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/DelegatingAIAgent.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/DelegatingAIAgent.cs index 6afc75b1d5..6945f22df8 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/DelegatingAIAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/DelegatingAIAgent.cs @@ -81,8 +81,8 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize => this.InnerAgent.SerializeSession(session, jsonSerializerOptions); /// - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) - => this.InnerAgent.DeserializeSessionAsync(serializedSession, jsonSerializerOptions, cancellationToken); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + => this.InnerAgent.DeserializeSessionAsync(serializedState, jsonSerializerOptions, cancellationToken); /// protected override Task RunCoreAsync( diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryAgentSession.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryAgentSession.cs index f2077cd844..05ffafaeb9 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryAgentSession.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryAgentSession.cs @@ -58,29 +58,29 @@ protected InMemoryAgentSession(IEnumerable messages) /// /// Initializes a new instance of the class from previously serialized state. /// - /// A representing the serialized state of the session. + /// A representing the serialized state of the session. /// Optional settings for customizing the JSON deserialization process. /// /// Optional factory function to create the from its serialized state. /// If not provided, a default factory will be used that creates a basic . /// - /// The is not a JSON object. - /// The is invalid or cannot be deserialized to the expected type. + /// The is not a JSON object. + /// The is invalid or cannot be deserialized to the expected type. /// /// This constructor enables restoration of in-memory threads from previously saved state, allowing /// conversations to be resumed across application restarts or migrated between different instances. /// protected InMemoryAgentSession( - JsonElement serializedSessionState, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, Func? chatHistoryProviderFactory = null) { - if (serializedSessionState.ValueKind != JsonValueKind.Object) + if (serializedState.ValueKind != JsonValueKind.Object) { - throw new ArgumentException("The serialized session state must be a JSON object.", nameof(serializedSessionState)); + throw new ArgumentException("The serialized session state must be a JSON object.", nameof(serializedState)); } - var state = serializedSessionState.Deserialize( + var state = serializedState.Deserialize( AgentAbstractionsJsonUtilities.DefaultOptions.GetTypeInfo(typeof(InMemoryAgentSessionState))) as InMemoryAgentSessionState; this.ChatHistoryProvider = diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/ServiceIdAgentSession.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/ServiceIdAgentSession.cs index 36557d7204..cf00635984 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/ServiceIdAgentSession.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/ServiceIdAgentSession.cs @@ -42,24 +42,24 @@ protected ServiceIdAgentSession(string serviceSessionId) /// /// Initializes a new instance of the class from previously serialized state. /// - /// A representing the serialized state of the session. + /// A representing the serialized state of the session. /// Optional settings for customizing the JSON deserialization process. - /// The is not a JSON object. - /// The is invalid or cannot be deserialized to the expected type. + /// The is not a JSON object. + /// The is invalid or cannot be deserialized to the expected type. /// /// This constructor enables restoration of a service-backed session from serialized state, typically used /// when deserializing session information that was previously saved or transmitted across application boundaries. /// protected ServiceIdAgentSession( - JsonElement serializedSessionState, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null) { - if (serializedSessionState.ValueKind != JsonValueKind.Object) + if (serializedState.ValueKind != JsonValueKind.Object) { - throw new ArgumentException("The serialized session state must be a JSON object.", nameof(serializedSessionState)); + throw new ArgumentException("The serialized session state must be a JSON object.", nameof(serializedState)); } - var state = serializedSessionState.Deserialize( + var state = serializedState.Deserialize( AgentAbstractionsJsonUtilities.DefaultOptions.GetTypeInfo(typeof(ServiceIdAgentSessionState))) as ServiceIdAgentSessionState; if (state?.ServiceSessionId is string serviceSessionId) diff --git a/dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs b/dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs index 100417f9a6..192cd863db 100644 --- a/dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs @@ -67,8 +67,8 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize } /// - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) - => new(new CopilotStudioAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + => new(new CopilotStudioAgentSession(serializedState, jsonSerializerOptions)); /// protected override async Task RunCoreAsync( diff --git a/dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md b/dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md index c0702abdce..db3eebde57 100644 --- a/dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md +++ b/dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md @@ -9,6 +9,7 @@ - Removed AgentThreadMetadata and used AgentSessionId directly instead ([#3067](https://github.com/microsoft/agent-framework/pull/3067)); - Renamed AgentThread to AgentSession ([#3430](https://github.com/microsoft/agent-framework/pull/3430)) - Moved AgentSession.Serialize to AIAgent.SerializeSession ([#3650](https://github.com/microsoft/agent-framework/pull/3650)) +- Renamed serializedSession parameter to serializedState on DeserializeSessionAsync for consistency ([#3681](https://github.com/microsoft/agent-framework/pull/3681)) ## v1.0.0-preview.251204.1 diff --git a/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs b/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs index 5e9f923f96..3253ba3b65 100644 --- a/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs @@ -64,15 +64,15 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize /// /// Deserializes an agent session from JSON. /// - /// The serialized session data. + /// The serialized session data. /// Optional JSON serializer options. /// The cancellation token. /// A value task that represents the asynchronous operation. The task result contains the deserialized agent session. public override ValueTask DeserializeSessionAsync( - JsonElement serializedSession, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { - return ValueTask.FromResult(DurableAgentSession.Deserialize(serializedSession, jsonSerializerOptions)); + return ValueTask.FromResult(DurableAgentSession.Deserialize(serializedState, jsonSerializerOptions)); } /// diff --git a/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.cs b/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.cs index 0a1be7028e..0a09257d9b 100644 --- a/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.cs +++ b/dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.cs @@ -27,10 +27,10 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize } public override ValueTask DeserializeSessionAsync( - JsonElement serializedSession, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { - return ValueTask.FromResult(DurableAgentSession.Deserialize(serializedSession, jsonSerializerOptions)); + return ValueTask.FromResult(DurableAgentSession.Deserialize(serializedState, jsonSerializerOptions)); } public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) diff --git a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs index eb4b804ff8..92a87ee471 100644 --- a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs @@ -112,10 +112,10 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize /// public override ValueTask DeserializeSessionAsync( - JsonElement serializedSession, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) - => new(new GitHubCopilotAgentSession(serializedSession, jsonSerializerOptions)); + => new(new GitHubCopilotAgentSession(serializedState, jsonSerializerOptions)); /// protected override Task RunCoreAsync( diff --git a/dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs b/dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs index 21343912af..fa6f55a9ac 100644 --- a/dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs @@ -36,9 +36,9 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize } /// - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { - return this._innerAgent.DeserializeSessionAsync(serializedSession, jsonSerializerOptions, cancellationToken); + return this._innerAgent.DeserializeSessionAsync(serializedState, jsonSerializerOptions, cancellationToken); } /// diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs index 3c7ff5542f..189ca43101 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs @@ -80,8 +80,8 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize return workflowSession.Serialize(jsonSerializerOptions); } - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) - => new(new WorkflowSession(this._workflow, serializedSession, this._executionEnvironment, this._checkpointManager, this._includeExceptionDetails, this._includeWorkflowOutputsInResponse, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + => new(new WorkflowSession(this._workflow, serializedState, this._executionEnvironment, this._checkpointManager, this._includeExceptionDetails, this._includeWorkflowOutputsInResponse, jsonSerializerOptions)); private async ValueTask UpdateSessionAsync(IEnumerable messages, AgentSession? session = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs index 8c0d2feaa2..ee6db4830d 100644 --- a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs @@ -399,7 +399,7 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize } /// - public override async ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override async ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { Func>? chatHistoryProviderFactory = this._agentOptions?.ChatHistoryProviderFactory is null ? null : @@ -410,7 +410,7 @@ public override async ValueTask DeserializeSessionAsync(JsonElemen (jse, jso, ct) => this._agentOptions.AIContextProviderFactory.Invoke(new() { SerializedState = jse, JsonSerializerOptions = jso }, ct); return await ChatClientAgentSession.DeserializeAsync( - serializedSession, + serializedState, jsonSerializerOptions, chatHistoryProviderFactory, aiContextProviderFactory, diff --git a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentSession.cs b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentSession.cs index e5edb3b629..1a79ae64d1 100644 --- a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentSession.cs +++ b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentSession.cs @@ -115,7 +115,7 @@ internal set /// /// Creates a new instance of the class from previously serialized state. /// - /// A representing the serialized state of the session. + /// A representing the serialized state of the session. /// Optional settings for customizing the JSON deserialization process. /// /// An optional factory function to create a custom from its serialized state. @@ -128,18 +128,18 @@ internal set /// The to monitor for cancellation requests. /// A task representing the asynchronous operation. The task result contains the deserialized . internal static async Task DeserializeAsync( - JsonElement serializedSessionState, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, Func>? chatHistoryProviderFactory = null, Func>? aiContextProviderFactory = null, CancellationToken cancellationToken = default) { - if (serializedSessionState.ValueKind != JsonValueKind.Object) + if (serializedState.ValueKind != JsonValueKind.Object) { - throw new ArgumentException("The serialized session state must be a JSON object.", nameof(serializedSessionState)); + throw new ArgumentException("The serialized session state must be a JSON object.", nameof(serializedState)); } - var state = serializedSessionState.Deserialize( + var state = serializedState.Deserialize( AgentJsonUtilities.DefaultOptions.GetTypeInfo(typeof(SessionState))) as SessionState; var session = new ChatClientAgentSession(); diff --git a/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIAgentTests.cs b/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIAgentTests.cs index c65cb66e59..900de7dc47 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIAgentTests.cs @@ -452,7 +452,7 @@ public override async ValueTask CreateSessionAsync(CancellationTok public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) => throw new NotImplementedException(); - public override async ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override async ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); protected override Task RunCoreAsync( @@ -487,7 +487,7 @@ public MockAgentWithName(string? name, string? description) public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/AggregatorPromptAgentFactoryTests.cs b/dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/AggregatorPromptAgentFactoryTests.cs index a0e3efcbb9..4a6709ac0a 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/AggregatorPromptAgentFactoryTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/AggregatorPromptAgentFactoryTests.cs @@ -66,7 +66,7 @@ public TestAgentFactory(AIAgent? agentToReturn = null) private sealed class TestAgent : AIAgent { - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.cs index 8f2770679a..e8e5b7269c 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.cs @@ -283,8 +283,8 @@ internal sealed class FakeChatClientAgent : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new FakeInMemoryAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(new FakeInMemoryAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(new FakeInMemoryAgentSession(serializedState, jsonSerializerOptions)); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) => throw new NotImplementedException(); @@ -350,8 +350,8 @@ internal sealed class FakeMultiMessageAgent : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new FakeInMemoryAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(new FakeInMemoryAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(new FakeInMemoryAgentSession(serializedState, jsonSerializerOptions)); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) { diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/ForwardedPropertiesTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/ForwardedPropertiesTests.cs index 4fad7ff1da..1872b9fbef 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/ForwardedPropertiesTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/ForwardedPropertiesTests.cs @@ -337,8 +337,8 @@ protected override async IAsyncEnumerable RunCoreStreamingA public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new FakeInMemoryAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(new FakeInMemoryAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(new FakeInMemoryAgentSession(serializedState, jsonSerializerOptions)); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) { diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/SharedStateTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/SharedStateTests.cs index 03102bf0ca..a20a7f6c04 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/SharedStateTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/SharedStateTests.cs @@ -420,8 +420,8 @@ stateObj is JsonElement state && public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new FakeInMemoryAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(new FakeInMemoryAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(new FakeInMemoryAgentSession(serializedState, jsonSerializerOptions)); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) { diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs index d3ae1e5d72..896ba929cf 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs @@ -428,8 +428,8 @@ private sealed class MultiResponseAgent : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new TestInMemoryAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(new TestInMemoryAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(new TestInMemoryAgentSession(serializedState, jsonSerializerOptions)); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) { @@ -531,8 +531,8 @@ private sealed class TestAgent : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new TestInMemoryAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(new TestInMemoryAgentSession(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(new TestInMemoryAgentSession(serializedState, jsonSerializerOptions)); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) { diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.UnitTests/TestAgent.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.UnitTests/TestAgent.cs index 8ece75304d..afacf590fb 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.UnitTests/TestAgent.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.UnitTests/TestAgent.cs @@ -17,7 +17,7 @@ public override JsonElement SerializeSession(AgentSession session, JsonSerialize => throw new NotImplementedException(); public override ValueTask DeserializeSessionAsync( - JsonElement serializedSession, + JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(new DummyAgentSession()); protected override Task RunCoreAsync( diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs index e703976a1e..a2bb76ea78 100644 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs @@ -388,7 +388,7 @@ public override ValueTask CreateSessionAsync(CancellationToken can public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) => throw new NotImplementedException(); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public override string? Name { get; } diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/TestAIAgent.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/TestAIAgent.cs index a394a8967e..db8f056218 100644 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/TestAIAgent.cs +++ b/dotnet/tests/Microsoft.Agents.AI.UnitTests/TestAIAgent.cs @@ -27,8 +27,8 @@ internal sealed class TestAIAgent : AIAgent public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) => throw new NotImplementedException(); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => - new(this.DeserializeSessionFunc(serializedSession, jsonSerializerOptions)); + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(this.DeserializeSessionFunc(serializedState, jsonSerializerOptions)); public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(this.CreateSessionFunc()); diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs index 8fb1502fda..e58260c8b0 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs @@ -138,7 +138,7 @@ private class DoubleEchoAgent(string name) : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new DoubleEchoAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(new DoubleEchoAgentSession()); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/InProcessExecutionTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/InProcessExecutionTests.cs index d24f6e263a..8517d68023 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/InProcessExecutionTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/InProcessExecutionTests.cs @@ -146,7 +146,7 @@ public SimpleTestAgent(string name) public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new SimpleTestAgentSession()); - public override ValueTask DeserializeSessionAsync(System.Text.Json.JsonElement serializedSession, + public override ValueTask DeserializeSessionAsync(System.Text.Json.JsonElement serializedState, System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(new SimpleTestAgentSession()); public override System.Text.Json.JsonElement SerializeSession(AgentSession session, System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RepresentationTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RepresentationTests.cs index b267eb7027..c76d7be1b5 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RepresentationTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RepresentationTests.cs @@ -27,7 +27,7 @@ private sealed class TestAgent : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RoleCheckAgent.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RoleCheckAgent.cs index dabfc149a3..190f572582 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RoleCheckAgent.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RoleCheckAgent.cs @@ -16,7 +16,7 @@ internal sealed class RoleCheckAgent(bool allowOtherAssistantRoles, string? id = public override string? Name => name; - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(new RoleCheckAgentSession()); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/06_GroupChat_Workflow.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/06_GroupChat_Workflow.cs index a19a70345b..f29c39a981 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/06_GroupChat_Workflow.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/06_GroupChat_Workflow.cs @@ -63,7 +63,7 @@ internal sealed class HelloAgent(string id = nameof(HelloAgent)) : AIAgent public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new HelloAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(new HelloAgentSession()); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestEchoAgent.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestEchoAgent.cs index 13cc95e992..d66443f069 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestEchoAgent.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestEchoAgent.cs @@ -16,9 +16,9 @@ internal class TestEchoAgent(string? id = null, string? name = null, string? pre protected override string? IdCore => id; public override string? Name => name ?? base.Name; - public override async ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override async ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { - return serializedSession.Deserialize(jsonSerializerOptions) ?? await this.CreateSessionAsync(cancellationToken); + return serializedState.Deserialize(jsonSerializerOptions) ?? await this.CreateSessionAsync(cancellationToken); } public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestReplayAgent.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestReplayAgent.cs index 282c168a14..065c751679 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestReplayAgent.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestReplayAgent.cs @@ -48,7 +48,7 @@ static ChatMessage ToMessage(string text) public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default) => new(new ReplayAgentSession()); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(new ReplayAgentSession()); public override JsonElement SerializeSession(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null) diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestRequestAgent.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestRequestAgent.cs index ce0be1b93e..6bed1e1649 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestRequestAgent.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestRequestAgent.cs @@ -37,7 +37,7 @@ public override ValueTask CreateSessionAsync(CancellationToken can _ => throw new NotSupportedException(), }); - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => new(requestType switch { TestAgentRequestType.FunctionCall => new TestRequestAgentSession(), diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs index e8b8a229c1..276c0c3973 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs @@ -41,9 +41,9 @@ public Session(JsonElement serializedSession, JsonSerializerOptions? jsonSeriali { } } - public override ValueTask DeserializeSessionAsync(JsonElement serializedSession, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + public override ValueTask DeserializeSessionAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { - return new(new Session(serializedSession, jsonSerializerOptions)); + return new(new Session(serializedState, jsonSerializerOptions)); } public override ValueTask CreateSessionAsync(CancellationToken cancellationToken = default)