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:
@@ -104,6 +104,10 @@ pub enum ToolResponse {
|
||||
},
|
||||
Denied {
|
||||
reason: DenyReason,
|
||||
/// Why the arguments were not valid, for `invalid_arguments` only. Written only when
|
||||
/// present, so a denial without one has the same bytes as before M5b.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
detail: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"v":1,"id":9,"final":true,"msg":{"kind":"tool_response","body":{"status":"denied","reason":"invalid_arguments","detail":"invalid argument shape: unknown field `file`, expected `text`"}}}
|
||||
@@ -68,6 +68,7 @@ fn envelopes_reject_unknown_keys_at_every_depth() {
|
||||
"tool_response_result.json",
|
||||
"tool_response_failed.json",
|
||||
"tool_response_denied.json",
|
||||
"tool_response_denied_detail.json",
|
||||
"error.json",
|
||||
"turn.json",
|
||||
"turn_event_tool_result.json",
|
||||
|
||||
@@ -94,10 +94,35 @@ fn tool_response_failed() {
|
||||
fn tool_response_denied() {
|
||||
let body = ToolResponse::Denied {
|
||||
reason: DenyReason::TaintTooHigh,
|
||||
detail: None,
|
||||
};
|
||||
check("tool_response_denied.json", response(9, true, body));
|
||||
}
|
||||
|
||||
/// A detail is written only when there is one, so the fixture above has no `detail` key.
|
||||
#[test]
|
||||
fn tool_response_denied_with_a_detail() {
|
||||
let body = ToolResponse::Denied {
|
||||
reason: DenyReason::InvalidArguments,
|
||||
detail: Some("invalid argument shape: unknown field `file`, expected `text`".to_string()),
|
||||
};
|
||||
check("tool_response_denied_detail.json", response(9, true, body));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_detail_must_be_a_string() {
|
||||
let good = fixture("tool_response_denied_detail.json");
|
||||
assert!(serde_json::from_str::<Envelope>(&good).is_ok());
|
||||
let at = good.find("\"detail\":").unwrap();
|
||||
for value in ["7", "[\"a\"]", "{}", "true"] {
|
||||
let bad = format!("{}\"detail\":{value}}}}}}}", &good[..at]);
|
||||
assert!(
|
||||
serde_json::from_str::<Envelope>(&bad).is_err(),
|
||||
"accepted {bad}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_message() {
|
||||
let body = WireError {
|
||||
|
||||
Reference in New Issue
Block a user