新增: 断点续跑与日志租约底座
This commit is contained in:
@@ -107,6 +107,7 @@ fn system_prompt_parts(lang: &str) -> (String, &'static str, &'static str) {
|
||||
- **Self-check before claiming completion**: Before announcing a task done, verify the result matches the original intent (grep key references / read back field values / cross-check). Fix discrepancies before declaring success; never claim all done without verification (repeatedly observed: missed reference renames, fields silently overwritten by later ops, forcing the user to manually verify)\n\
|
||||
- {}\n\
|
||||
- {}\n\
|
||||
- {}\n\
|
||||
## Focus\n\
|
||||
- Always center your response on the core goal of the user's current request; the previous round's topic is only background, not the current task.\n\
|
||||
- When the user switches topics (a clear new intent), follow the latest request; do not drag the old topic into the new answer.\n\
|
||||
@@ -115,6 +116,7 @@ fn system_prompt_parts(lang: &str) -> (String, &'static str, &'static str) {
|
||||
read_symbol_guidance(lang),
|
||||
duplicate_call_guidance(lang),
|
||||
file_reading_guidance(lang),
|
||||
verification_fast_check_guidance(lang),
|
||||
),
|
||||
"\n## Current Projects\n",
|
||||
"\n## Current Tasks\n",
|
||||
@@ -138,6 +140,7 @@ fn system_prompt_parts(lang: &str) -> (String, &'static str, &'static str) {
|
||||
- 工具调用失败时必须明确告知用户失败原因,严禁用替代操作冒充原意图成功(如绑定目录失败不得改写描述冒充已绑定),也绝不谎报成功\n\
|
||||
- {}\n\
|
||||
- {}\n\
|
||||
- {}\n\
|
||||
## 聚焦准则\n\
|
||||
- 始终围绕用户当前请求的核心目标回答;上一轮的主题只是背景,不是当前任务。\n\
|
||||
- 用户切换话题(明显的新意图)时,以最新请求为准,不要把旧话题带进新回答。\n\
|
||||
@@ -146,6 +149,7 @@ fn system_prompt_parts(lang: &str) -> (String, &'static str, &'static str) {
|
||||
read_symbol_guidance(lang),
|
||||
duplicate_call_guidance(lang),
|
||||
file_reading_guidance(lang),
|
||||
verification_fast_check_guidance(lang),
|
||||
),
|
||||
"\n## 当前项目\n",
|
||||
"\n## 当前任务\n",
|
||||
@@ -207,6 +211,16 @@ fn file_reading_guidance(lang: &str) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// 验证快检纪律(中/英,不含行首 "- ")。狗粮实证(2026-10-04):验证阶段多次全量
|
||||
/// cargo check(单次数十秒)烧轮。开发中途单文件/单包改动用窄域快检,全量验证只留
|
||||
/// 给阶段收官一次。
|
||||
fn verification_fast_check_guidance(lang: &str) -> &'static str {
|
||||
match lang {
|
||||
"en" => "**Fast-check discipline**: during development, verify with narrow-scope checks first — `cargo check -p <package>` for one crate, read back the edited snippet for a single-file change. Full-workspace `cargo check`/`cargo test` is for final acceptance ONLY (run once per milestone, not per patch); repeated full checks burn minutes per round",
|
||||
_ => "**验证快检纪律**:开发中途优先窄域验证——单包改动用 `cargo check -p <包名>`,单文件改动回读编辑片段即可。全量 cargo check/cargo test 只留给阶段收官(每个里程碑一次,不要每个小 patch 跑一遍);反复全量验证每轮烧数十秒",
|
||||
}
|
||||
}
|
||||
|
||||
/// 子代理工具纪律段(P1-1):与父会话 system prompt 同源拼接的工具使用纪律 ——
|
||||
/// read_symbol 优先 / 重复调用检测 / URL 三工具纪律与禁臆造 URL / render=true 失败
|
||||
/// 2 次必换方案 / 查配置用 get_app_config。子代理白名单缺省下发全量 Low 工具,
|
||||
@@ -218,10 +232,13 @@ pub(crate) fn sub_agent_tool_discipline_section(lang: &str) -> String {
|
||||
"\n## 工具纪律\n\
|
||||
- {}\n\
|
||||
- {}\n\
|
||||
- {}\n{}{}",
|
||||
- {}\n\
|
||||
- {}\n\
|
||||
{}{}",
|
||||
read_symbol_guidance(lang),
|
||||
duplicate_call_guidance(lang),
|
||||
file_reading_guidance(lang),
|
||||
verification_fast_check_guidance(lang),
|
||||
doc_strategy_core_section(lang),
|
||||
app_config_query_guidance_section(lang),
|
||||
)
|
||||
@@ -724,6 +741,9 @@ pub(crate) fn compress_prompt(lang: &str) -> &'static str {
|
||||
- Must preserve core topic words, entity names, and technical terms the user \
|
||||
repeatedly mentions; they are anchors for continuing the conversation and losing \
|
||||
them breaks the context thread.\n\
|
||||
- MUST preserve rejection/failed facts verbatim: failed tool calls with error \
|
||||
messages, proposals or approaches the user rejected (with stated reasons), and \
|
||||
forbidden operations — losing them invites blindly retrying failed paths.\n\
|
||||
- Do NOT invent facts not present in the conversation.\n\
|
||||
- Output the four sections only, no preamble or extra commentary.",
|
||||
_ => "你是对话总结器。请把以下对话压缩为结构化摘要,保留继续推进工作所必需的关键上下文。\
|
||||
@@ -746,6 +766,7 @@ pub(crate) fn compress_prompt(lang: &str) -> &'static str {
|
||||
- 去掉寒暄、过渡性客套,只保留技术上有价值的事实。\n\
|
||||
- 文件路径、标识符、错误信息等照原样保留。\n\
|
||||
- 必须保留用户反复提及的核心主题词、实体名、技术名词(它们是对话续接的锚点,丢失会致上下文断裂)。\n\
|
||||
- 必须原样保留「被拒/失败」事实:失败的工具调用及其错误信息、用户明确否决的方案及理由、明令禁止的操作——丢失会导致压缩后盲目重走失败路径。\n\
|
||||
- 不要编造对话中没有的事实。\n\
|
||||
- 只输出上述四段内容,不要前言、解释或额外评论。",
|
||||
}
|
||||
@@ -915,6 +936,26 @@ mod tests {
|
||||
assert!(en.contains("breaks the context"));
|
||||
}
|
||||
|
||||
// B-2(2026-10-05 拍板): 压缩 prompt 被拒/失败事实保留条款(防压缩后盲目重走失败路径)
|
||||
#[test]
|
||||
fn compress_prompt_keeps_rejection_facts_clause() {
|
||||
let zh = compress_prompt("zh-CN");
|
||||
assert!(
|
||||
zh.contains("被拒/失败"),
|
||||
"中文 compress_prompt 应含被拒/失败事实保留条款,实际: {}",
|
||||
zh
|
||||
);
|
||||
assert!(zh.contains("盲目重走失败路径"));
|
||||
|
||||
let en = compress_prompt("en");
|
||||
assert!(
|
||||
en.contains("preserve rejection/failed facts"),
|
||||
"英文 compress_prompt 应含 rejection/failed facts 保留条款,实际: {}",
|
||||
en
|
||||
);
|
||||
assert!(en.contains("blindly retrying failed paths"));
|
||||
}
|
||||
|
||||
// 查 DevFlow 自身配置引导段(中/英)存在且含关键引导
|
||||
#[test]
|
||||
fn app_config_query_guidance_section_present_zh_en() {
|
||||
|
||||
Reference in New Issue
Block a user