Guide models to read-only inspection: prompt rules, pipes and find in the read-only gate, approval stats
This commit is contained in:
1 parent
8345d0f504
commit
37dfbc3102
7 files changed
+70
-11
No files matched your search
@@ -135,6 +135,34 @@ pub fn report(s: &Session) -> String {
|
||||
call_b / 4
|
||||
);
|
||||
|
||||
// bash calls that ask for approval, by first word: shows which habits break the read-only flow
|
||||
let mut asks: HashMap<String, u32> = HashMap::new();
|
||||
for m in msgs.iter().filter(|m| m.role == Role::Assistant) {
|
||||
for b in &m.content {
|
||||
if let ContentBlock::ToolUse { name, input, .. } = b
|
||||
&& name == "bash"
|
||||
&& crate::permit::needs_permit(name, input)
|
||||
{
|
||||
{
|
||||
let c = input["command"].as_str().unwrap_or_default();
|
||||
*asks
|
||||
.entry(c.split_whitespace().next().unwrap_or("").into())
|
||||
.or_default() += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !asks.is_empty() {
|
||||
let mut v: Vec<_> = asks.into_iter().collect();
|
||||
v.sort_by(|a, b| b.1.cmp(&a.1).then(a.0.cmp(&b.0)));
|
||||
let list: Vec<String> = v.iter().take(8).map(|(c, n)| format!("{c} {n}")).collect();
|
||||
let _ = writeln!(
|
||||
o,
|
||||
"approval prompts from bash, by command: {}",
|
||||
list.join(", ")
|
||||
);
|
||||
}
|
||||
|
||||
// carried cost of tool results on the current path
|
||||
let mut names: HashMap<&str, &str> = HashMap::new();
|
||||
for m in &msgs {
|
||||
|
||||
Reference in new issue
Block a user