优化: 弱模型治理收尾(AC-2探索预算:单轮上限+目录去重+禁绕行 + AC-5失败画像:合法目标回灌+相近锚点提示)
This commit is contained in:
@@ -355,6 +355,15 @@ pub(crate) fn is_pure_greeting(msg: &str) -> bool {
|
||||
!ACTION_WORDS.iter().any(|a| lower.contains(a))
|
||||
}
|
||||
|
||||
/// AC-2 ①:单轮工具调用数超限判定(纯函数,供 run_agentic_loop 每轮调用)。
|
||||
///
|
||||
/// 治弱模型单轮一次性发超多工具调用(实证 09e7abfa:同一目录列 3 次 + run_command 绕行,
|
||||
/// 单轮十几个 grep/read 并行爆炸)。LLM 看不到"自己本轮发了多少调用",超限必须在
|
||||
/// 消息流里显式警告(机制优先 prompt 说教)。纯函数便于单测边界。
|
||||
pub(crate) fn is_tool_call_over_limit(count: usize) -> bool {
|
||||
count > super::MAX_TOOL_CALLS_PER_ROUND
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -553,4 +562,18 @@ mod tests {
|
||||
fn greeting_ok_is_greeting() {
|
||||
assert!(is_pure_greeting("ok"));
|
||||
}
|
||||
|
||||
// ── AC-2 ① 单轮工具调用数上限判定测试 ──
|
||||
|
||||
#[test]
|
||||
fn tool_call_limit_at_threshold_not_over() {
|
||||
assert!(!is_tool_call_over_limit(super::super::MAX_TOOL_CALLS_PER_ROUND), "恰好达上限不触发");
|
||||
assert!(!is_tool_call_over_limit(0));
|
||||
assert!(!is_tool_call_over_limit(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tool_call_limit_over_threshold() {
|
||||
assert!(is_tool_call_over_limit(super::super::MAX_TOOL_CALLS_PER_ROUND + 1), "超上限触发");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user