优化: 弱模型工具行为治理(项目/任务清单补id + 缓存命中警告 + read_symbol 提示)
This commit is contained in:
@@ -182,8 +182,21 @@ pub fn register(
|
||||
consumed,
|
||||
))
|
||||
} else { None };
|
||||
// 机制提示(AC-4,治弱模型 read_file 全量回灌):内容读取成功且扩展名在 read_symbol
|
||||
// 支持语言集合内,则末尾追加一句引导提示改用 read_symbol 精确提取符号,避免读全文件
|
||||
// 浪费上下文。复用 code_intel::is_supported_ext 单真相源(与 read_symbol handler 语言
|
||||
// 集合一致,不重复定义)。仅首次读取(无 offset)追加,offset 分页续读不重复提示防噪音。
|
||||
let content_field = if offset_used.is_none()
|
||||
&& crate::commands::ai::code_intel::is_supported_ext(
|
||||
path.rsplit('.').next().unwrap_or("").to_lowercase().as_str(),
|
||||
)
|
||||
{
|
||||
format!("{result}\n[提示] 如需定位该文件的函数/类/符号,请改用 read_symbol(路径, 符号名) 精确提取,避免读全文件浪费上下文。")
|
||||
} else {
|
||||
result
|
||||
};
|
||||
Ok(serde_json::json!({
|
||||
"path": path, "content": result, "size": metadata.len(), "file_hash": file_hash, "lines": line_count,
|
||||
"path": path, "content": content_field, "size": metadata.len(), "file_hash": file_hash, "lines": line_count,
|
||||
"offset": offset_used,
|
||||
"returned_lines": returned_lines,
|
||||
"truncated": has_more,
|
||||
|
||||
Reference in New Issue
Block a user