From 51b992cfd5616ce3edfbef11482bdca6b285010d Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 27 Jan 2025 11:54:48 -0500 Subject: [PATCH] add xml comments for AgentProxy.cs --- .../Contracts/PythonEquiv/AgentProxy.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentProxy.cs b/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentProxy.cs index 4e174c8b9..d73313f1f 100644 --- a/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentProxy.cs +++ b/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentProxy.cs @@ -4,9 +4,19 @@ namespace Microsoft.AutoGen.Contracts.Python; +/// +/// A helper class that allows you to use an in place of its associated . +/// public class AgentProxy(AgentId agentId, IAgentRuntime runtime) { + /// + /// The runtime instance used to interact with agents. + /// private IAgentRuntime runtime = runtime; + + /// + /// The target agent for this proxy. + /// public AgentId Id = agentId; private T ExecuteAndUnwrap(Func> delegate_) @@ -14,19 +24,47 @@ public class AgentProxy(AgentId agentId, IAgentRuntime runtime) return delegate_(this.runtime).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); } + /// + /// Gets the metadata of the agent. + /// + /// + /// An instance of containing details about the agent. + /// public AgentMetadata Metadata => this.ExecuteAndUnwrap(runtime => runtime.GetAgentMetadataAsync(this.Id)); // TODO: make this optional + /// + /// Sends a message to the agent and processes the response. + /// + /// The message to send to the agent. + /// The agent that is sending the message. + /// + /// The message ID. If null, a new message ID will be generated. + /// This message ID must be unique and is recommended to be a UUID. + /// + /// + /// A token used to cancel an in-progress operation. Defaults to null. + /// + /// A task representing the asynchronous operation, returning the response from the agent. public ValueTask SendMessageAsync(object message, AgentId sender, string? messageId = null, CancellationToken? cancellationToken = default) { return this.runtime.SendMessageAsync(message, this.Id, sender, messageId, cancellationToken); } + /// + /// Loads the state of the agent from a previously saved state. + /// + /// A dictionary representing the state of the agent. Must be JSON serializable. + /// A task representing the asynchronous operation. public ValueTask LoadStateAsync(IDictionary state) { return this.runtime.LoadAgentStateAsync(state); } + /// + /// Saves the state of the agent. The result must be JSON serializable. + /// + /// A task representing the asynchronous operation, returning a dictionary containing the saved state. public ValueTask> SaveStateAsync() { return this.runtime.SaveAgentStateAsync();