fix(channels): execute tool calls in channel runtime (#302)
* fix(channels): execute tool calls in channel runtime (#302) * chore(fmt): align repo formatting with rustfmt 1.92
This commit is contained in:
parent
efabe9703f
commit
9d29f30a31
17 changed files with 483 additions and 127 deletions
|
|
@ -124,7 +124,10 @@ impl HttpRequestTool {
|
|||
|
||||
fn truncate_response(&self, text: &str) -> String {
|
||||
if text.len() > self.max_response_size {
|
||||
let mut truncated = text.chars().take(self.max_response_size).collect::<String>();
|
||||
let mut truncated = text
|
||||
.chars()
|
||||
.take(self.max_response_size)
|
||||
.collect::<String>();
|
||||
truncated.push_str("\n\n... [Response truncated due to size limit] ...");
|
||||
truncated
|
||||
} else {
|
||||
|
|
@ -221,7 +224,10 @@ impl Tool for HttpRequestTool {
|
|||
|
||||
let sanitized_headers = self.sanitize_headers(&headers_val);
|
||||
|
||||
match self.execute_request(&url, method, sanitized_headers, body).await {
|
||||
match self
|
||||
.execute_request(&url, method, sanitized_headers, body)
|
||||
.await
|
||||
{
|
||||
Ok(response) => {
|
||||
let status = response.status();
|
||||
let status_code = status.as_u16();
|
||||
|
|
@ -407,7 +413,12 @@ mod tests {
|
|||
autonomy: AutonomyLevel::Supervised,
|
||||
..SecurityPolicy::default()
|
||||
});
|
||||
HttpRequestTool::new(security, allowed_domains.into_iter().map(String::from).collect(), 1_000_000, 30)
|
||||
HttpRequestTool::new(
|
||||
security,
|
||||
allowed_domains.into_iter().map(String::from).collect(),
|
||||
1_000_000,
|
||||
30,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -598,8 +609,14 @@ mod tests {
|
|||
});
|
||||
let sanitized = tool.sanitize_headers(&headers);
|
||||
assert_eq!(sanitized.len(), 3);
|
||||
assert!(sanitized.iter().any(|(k, v)| k == "Authorization" && v == "***REDACTED***"));
|
||||
assert!(sanitized.iter().any(|(k, v)| k == "X-API-Key" && v == "***REDACTED***"));
|
||||
assert!(sanitized.iter().any(|(k, v)| k == "Content-Type" && v == "application/json"));
|
||||
assert!(sanitized
|
||||
.iter()
|
||||
.any(|(k, v)| k == "Authorization" && v == "***REDACTED***"));
|
||||
assert!(sanitized
|
||||
.iter()
|
||||
.any(|(k, v)| k == "X-API-Key" && v == "***REDACTED***"));
|
||||
assert!(sanitized
|
||||
.iter()
|
||||
.any(|(k, v)| k == "Content-Type" && v == "application/json"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,7 +320,15 @@ mod tests {
|
|||
},
|
||||
);
|
||||
|
||||
let tools = all_tools(&security, mem, None, &browser, &http, &agents, Some("sk-test"));
|
||||
let tools = all_tools(
|
||||
&security,
|
||||
mem,
|
||||
None,
|
||||
&browser,
|
||||
&http,
|
||||
&agents,
|
||||
Some("sk-test"),
|
||||
);
|
||||
let names: Vec<&str> = tools.iter().map(|t| t.name()).collect();
|
||||
assert!(names.contains(&"delegate"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue