// Copyright (c) Microsoft. All rights reserved.
using System;
using Microsoft.Extensions.AI;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI;
///
/// Provides optional parameters and configuration settings for controlling agent run behavior.
///
///
///
/// Implementations of may provide subclasses of with additional options specific to that agent type.
///
///
public class AgentRunOptions
{
///
/// Initializes a new instance of the class.
///
public AgentRunOptions()
{
}
///
/// Initializes a new instance of the class by copying values from the specified options.
///
/// The options instance from which to copy values.
/// is .
public AgentRunOptions(AgentRunOptions options)
{
_ = Throw.IfNull(options);
this.ContinuationToken = options.ContinuationToken;
this.AllowBackgroundResponses = options.AllowBackgroundResponses;
this.AdditionalProperties = options.AdditionalProperties?.Clone();
}
///
/// Gets or sets the continuation token for resuming and getting the result of the agent response identified by this token.
///
///
/// This property is used for background responses that can be activated via the
/// property if the implementation supports them.
/// Streamed background responses, such as those returned by default by
/// can be resumed if interrupted. This means that a continuation token obtained from the
/// of an update just before the interruption occurred can be passed to this property to resume the stream from the point of interruption.
/// Non-streamed background responses, such as those returned by ,
/// can be polled for completion by obtaining the token from the property
/// and passing it via this property on subsequent calls to .
///
public ResponseContinuationToken? ContinuationToken { get; set; }
///
/// Gets or sets a value indicating whether the background responses are allowed.
///
///
///
/// Background responses allow running long-running operations or tasks asynchronously in the background that can be resumed by streaming APIs
/// and polled for completion by non-streaming APIs.
///
///
/// When this property is set to true, non-streaming APIs may start a background operation and return an initial
/// response with a continuation token. Subsequent calls to the same API should be made in a polling manner with
/// the continuation token to get the final result of the operation.
///
///
/// When this property is set to true, streaming APIs may also start a background operation and begin streaming
/// response updates until the operation is completed. If the streaming connection is interrupted, the
/// continuation token obtained from the last update that has one should be supplied to a subsequent call to the same streaming API
/// to resume the stream from the point of interruption and continue receiving updates until the operation is completed.
///
///
/// This property only takes effect if the implementation it's used with supports background responses.
/// If the implementation does not support background responses, this property will be ignored.
///
///
public bool? AllowBackgroundResponses { get; set; }
///
/// Gets or sets additional properties associated with these options.
///
///
/// An containing custom properties,
/// or if no additional properties are present.
///
///
/// Additional properties provide a way to include custom metadata or provider-specific
/// information that doesn't fit into the standard options schema. This is useful for
/// preserving implementation-specific details or extending the options with custom data.
///
public AdditionalPropertiesDictionary? AdditionalProperties { get; set; }
}