新增: 上下文管理演进 Wave3(T5 WorkingContext 层注入)
PerConvState: 新增 working_context 字段 - 初始化 WorkingContext::new() 默认空 system_prompt 注入: - L1a: 当前步骤(每轮必带,调用 build_injection) - L1b: 脏标记条件注入(dirty_window=3,有变更才带) - 拼入「## 工作上下文」段 T3 联动: compress 成功后的 reset_all 占位已在 context_lifecycle.rs 预埋 T4: 工作流注入点保留为独立段(待 workflow_id 字段落地) L1c (read_context 工具): 待注册(依赖 tool_registry 接线)
This commit is contained in:
@@ -859,6 +859,18 @@ pub(crate) async fn run_agentic_loop(
|
||||
}
|
||||
}
|
||||
|
||||
// T5: WorkingContext L1 注入(L1a 常驻 + L1b 条件注入)
|
||||
// 读取工作上下文,构建 L1 注入文本并拼入 system_prompt
|
||||
{
|
||||
let session = session_arc.lock().await;
|
||||
if let Some(conv) = session.conv_read(&conv_id) {
|
||||
let injection = conv.working_context.build_injection(3); // dirty_window=3
|
||||
if !injection.is_empty() {
|
||||
system_prompt = format!("{}\n\n## 工作上下文\n{}", system_prompt, injection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EnvSnapshot 环境感知:入口把当前平台的真实环境(OS/shell/工具版本)拼进 system_prompt 尾部。
|
||||
//
|
||||
// 治「LLM 跨平台命令幻觉」:LLM 训练数据 Unix 多,易生成 macOS/Linux 语法命令(PowerShell 5
|
||||
|
||||
Reference in New Issue
Block a user