mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* Add a StateBag to AgentSession and pass Agent and AgentSession to AIContextProvider and ChatHistoryProviders * Convert all AIContextProviders to use the statebag * Update InMemoryChatHistoryProvider to use StateBag * Update Comsos and Workflow ChatHistoryProviders * Update 3rd party chat history storage sample. * Remove serialize method from providers * Replacing provider factories with properties * Remove Providers from Session and flatten state bag serialization * Update samples to use getservice on agent * Updated additional session types to serialize statebag * Fix regression * Address PR comments * Address PR comments. * Fix formatting * Fix unit tests * Remove InMemoryAgentSession since it is not required anymore. * Address PR comments * Convert sessions for A2AAgent, ChatClientAgent, CopilotStudioAgent and GithubCopilotAgent to use regular json serialization. * Fix durable agent session jso usgae * Add jso to InMemory and Workflow ChatHistoryProviders * Update InMemoryChatHistoryProvider to use an options class for it's many optional settings. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address PR feedback * Fix verification bug. * Improve state bag thread safety * Address PR comments and fix unit tests * Address PR comments * Fix unit test --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
namespace Microsoft.Agents.AI;
|
|
|
|
/// <summary>
|
|
/// Options controlling the behavior of <see cref="ChatHistoryMemoryProvider"/>.
|
|
/// </summary>
|
|
public sealed class ChatHistoryMemoryProviderOptions
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets a value indicating when the search should be executed.
|
|
/// </summary>
|
|
/// <value><see cref="SearchBehavior.BeforeAIInvoke"/> by default.</value>
|
|
public SearchBehavior SearchTime { get; set; } = SearchBehavior.BeforeAIInvoke;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the name of the exposed search tool when operating in on-demand mode.
|
|
/// </summary>
|
|
/// <value>Defaults to "Search".</value>
|
|
public string? FunctionToolName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the description of the exposed search tool when operating in on-demand mode.
|
|
/// </summary>
|
|
/// <value>Defaults to "Allows searching through previous chat history to help answer the user question.".</value>
|
|
public string? FunctionToolDescription { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the context prompt prefixed to results.
|
|
/// </summary>
|
|
public string? ContextPrompt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the maximum number of results to retrieve from the chat history.
|
|
/// </summary>
|
|
/// <value>
|
|
/// Defaults to 3 if not set.
|
|
/// </value>
|
|
public int? MaxResults { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets a value indicating whether sensitive data such as user ids and user messages may appear in logs.
|
|
/// </summary>
|
|
/// <value>Defaults to <see langword="false"/>.</value>
|
|
public bool EnableSensitiveTelemetryData { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the key used to store provider state in the <see cref="AgentSession.StateBag"/>.
|
|
/// </summary>
|
|
/// <value>
|
|
/// Defaults to "ChatHistoryMemoryProvider.State". Override this if you need multiple
|
|
/// <see cref="ChatHistoryMemoryProvider"/> instances with separate state in the same session.
|
|
/// </value>
|
|
public string? StateKey { get; set; }
|
|
|
|
/// <summary>
|
|
/// Behavior choices for the provider.
|
|
/// </summary>
|
|
public enum SearchBehavior
|
|
{
|
|
/// <summary>
|
|
/// Execute search prior to each invocation and inject results as a message.
|
|
/// </summary>
|
|
BeforeAIInvoke,
|
|
|
|
/// <summary>
|
|
/// Expose a function tool to perform search on-demand via function/tool calling.
|
|
/// </summary>
|
|
OnDemandFunctionCalling
|
|
}
|
|
}
|