修复: system_prompt 追加行为准则,减少 LLM 写脚本偏好
This commit is contained in:
10
fix_prompt.py
Normal file
10
fix_prompt.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import re
|
||||
|
||||
with open("src-tauri/src/commands/ai/agentic/mod.rs", "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
old = 'let behavior_prompt = "\\n## 行为准则\\n- 优先使用开发工具指令(create_project/write_file/grep/read_file 等)完成任务,不要写独立的 Python/Shell 脚本\\n- 写脚本需要执行(run_command),执行需要审批通过,会显著拖慢工作流\\n- 已有 40+ 工具可覆盖绝大多数场景,先查工具列表再决定";'
|
||||
new = 'let behavior_prompt = "\\n## 行为准则\\n- 使用工具指令(create_project/write_file/grep/read_file/run_command 等)直接完成任务,不要让用户去终端执行命令\\n- 优先使用开发工具 IPC,非必要不写独立脚本(write_file + run_command = 两次审批,拖慢工作流)\\n- 已有 40+ 工具覆盖绝大多数场景,先查工具列表再决定";'
|
||||
content = content.replace(old, new, 1)
|
||||
with open("src-tauri/src/commands/ai/agentic/mod.rs", "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
print("done")
|
||||
@@ -830,7 +830,8 @@ pub(crate) async fn run_agentic_loop(
|
||||
// 输出平台一致性。detect() 是 OnceLock 全局缓存(启动时探一次,后续零开销),与 G1 一样
|
||||
// 是 loop 不变量(整个会话不重探),与目标钉扎拼接次序无强约束(放其后,语义自然)。
|
||||
let env_prompt = df_execute::EnvSnapshot::detect().await.to_prompt();
|
||||
system_prompt = format!("{}\n\n{}", system_prompt, env_prompt);
|
||||
let behavior_prompt = "\n## 行为准则\n- 使用工具指令(create_project/write_file/grep/read_file/run_command 等)直接完成任务,不要让用户去终端执行命令\n- 优先使用开发工具 IPC,非必要不写独立脚本(write_file + run_command = 两次审批,拖慢工作流)\n- 已有 40+ 工具覆盖绝大多数场景,先查工具列表再决定";
|
||||
system_prompt = format!("{}\n\n{}\n\n{}", system_prompt, env_prompt, behavior_prompt);
|
||||
|
||||
// 对话透明化 L1:拍快照供 AiCompleted 事件携带,前端直接读取 pinned_goals 无需等 loadConversations
|
||||
let pinned_goals_snapshot: Vec<String> = {
|
||||
|
||||
Reference in New Issue
Block a user