This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using System.Threading;
using AI.Models;
namespace AI.Service
{
/// <summary>
/// 当前会话上下文,供在 Kernel 工具调用(如知识库插件)中获取当前 ChatSession,以便将结果写入 Store。
/// 由 KernelService 在 AskAsync/AskStreamAsync 开始时设置,结束时清空。
/// </summary>
public static class CurrentSessionContext
private static readonly AsyncLocal<ChatSession?> _current = new();
/// 当前正在处理的聊天会话(仅在 LLM 调用链内有效)。
public static ChatSession? Current
get => _current.Value;
set => _current.Value = value;
}