using System.Threading; using AI.Models; namespace AI.Service { /// /// 当前会话上下文,供在 Kernel 工具调用(如知识库插件)中获取当前 ChatSession,以便将结果写入 Store。 /// 由 KernelService 在 AskAsync/AskStreamAsync 开始时设置,结束时清空。 /// public static class CurrentSessionContext { private static readonly AsyncLocal _current = new(); /// /// 当前正在处理的聊天会话(仅在 LLM 调用链内有效)。 /// public static ChatSession? Current { get => _current.Value; set => _current.Value = value; } } }