Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant2: Skip tool uses without a matching tool result (#27082)

Agus Zubiaga5f398071b283
diff --git a/crates/assistant2/src/tool_use.rs b/crates/assistant2/src/tool_use.rs
index 2045aa9b736..e0d03edd91a 100644
--- a/crates/assistant2/src/tool_use.rs
+++ b/crates/assistant2/src/tool_use.rs
@@ -286,9 +286,17 @@ impl ToolUseState {
) {
if let Some(tool_uses) = self.tool_uses_by_assistant_message.get(&message_id) {
for tool_use in tool_uses {
- request_message
- .content
- .push(MessageContent::ToolUse(tool_use.clone()));
+ if self.tool_results.contains_key(&tool_use.id) {
+ // Do not send tool uses until they are completed
+ request_message
+ .content
+ .push(MessageContent::ToolUse(tool_use.clone()));
+ } else {
+ log::debug!(
+ "skipped tool use {:?} because it is still pending",
+ tool_use
+ );
+ }
}
}
}