Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_repr = "0.1"
thiserror = "2"
tokio = { version = "1.52.2", features = ["sync", "macros"] }
tokio = { version = "1.52.3", features = ["sync", "macros", "time"] }
uuid = { version = "1", features = ["v4", "serde"] }
tracing = "0.1"

Expand Down
1 change: 1 addition & 0 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
//! ```

mod bare;
pub mod middleware;

pub use bare::*;
89 changes: 53 additions & 36 deletions src/engine/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,45 +670,62 @@ impl<C: ApiClient> BareLoop<C> {
self.notify_tool_call(&tc.name, &tc.input.to_string());
let start = Instant::now();
let tool_result = match self.tools.get(&tc.name) {
Some(tool) => match tool.call(tc.input.clone(), &tool_context).await {
Ok(result) => {
let duration = start.elapsed();
let output_text = result.text_content();
let success = !result.is_error;
self.notify_tool_complete(
&tc.name,
&tc.input.to_string(),
&output_text,
duration,
success,
None,
);
ToolCallResult {
tool_call_id: tc.id.clone(),
output: result.payload,
is_error: result.is_error,
duration,
Some(tool) => {
let cancel = Arc::clone(&self.cancelled);
let call_result = tokio::select! {
r = tool.call(tc.input.clone(), &tool_context) => r,
() = cancel.notified() => {
self.notify_tool_complete(
&tc.name,
&tc.input.to_string(),
"",
start.elapsed(),
false,
Some("cancelled"),
);
return Err(AgentError::Cancelled);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Err(e) => {
let duration = start.elapsed();
let error_msg = e.to_string();
self.notify_tool_complete(
&tc.name,
&tc.input.to_string(),
&error_msg,
duration,
false,
Some(&error_msg),
);
ToolCallResult {
tool_call_id: tc.id.clone(),
output: ToolContent::Text(error_msg),
is_error: true,
duration,
};
match call_result {
Ok(result) => {
let duration = start.elapsed();
let output_text = result.text_content();
let success = !result.is_error;
self.notify_tool_complete(
&tc.name,
&tc.input.to_string(),
&output_text,
duration,
success,
None,
);
ToolCallResult {
tool_call_id: tc.id.clone(),
output: result.payload,
is_error: result.is_error,
duration,
}
}
Err(e) => {
let duration = start.elapsed();
let error_msg = e.to_string();
self.notify_tool_complete(
&tc.name,
&tc.input.to_string(),
&error_msg,
duration,
false,
Some(&error_msg),
);
ToolCallResult {
tool_call_id: tc.id.clone(),
output: ToolContent::Text(error_msg),
is_error: true,
duration,
}
}
}
},
}
None => {
let available: Vec<String> = self.tools.tool_names().clone();
let available_refs: Vec<&str> = available.iter().map(String::as_str).collect();
Expand Down
Loading
Loading