bxcore, brokerd, loopd: an invalid-arguments denial says why
Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
@@ -378,6 +378,19 @@ pub fn denial_text(reason: bxcore::DenyReason) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// What a denial reaches the model as: the reason's sentence, and the broker's detail, if it sent
|
||||
/// one, after a colon (`Denied: the arguments are not valid for this tool: <detail>.`).
|
||||
pub fn denial_message(reason: bxcore::DenyReason, detail: Option<&str>) -> String {
|
||||
let sentence = denial_text(reason);
|
||||
match detail {
|
||||
None => sentence.to_string(),
|
||||
Some(detail) => {
|
||||
let stem = sentence.strip_suffix('.').unwrap_or(sentence);
|
||||
format!("{stem}: {detail}.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FakeTools {
|
||||
calls: Mutex<Vec<bxcore::ToolRequest>>,
|
||||
}
|
||||
@@ -432,6 +445,7 @@ impl ToolPort for FakeTools {
|
||||
},
|
||||
_ => bxcore::ToolResponse::Denied {
|
||||
reason: bxcore::DenyReason::NoGrant,
|
||||
detail: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user