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.

agent: Re-add workaround for language model behavior with empty tool result (#37196)

Cole Miller1c2e2a00fe87
diff --git a/crates/agent2/src/thread.rs b/crates/agent2/src/thread.rs
index 97ea1caf1d7..8ff5b845066 100644
--- a/crates/agent2/src/thread.rs
+++ b/crates/agent2/src/thread.rs
@@ -484,11 +484,15 @@ impl AgentMessage {
};
for tool_result in self.tool_results.values() {
+ let mut tool_result = tool_result.clone();
+ // Surprisingly, the API fails if we return an empty string here.
+ // It thinks we are sending a tool use without a tool result.
+ if tool_result.content.is_empty() {
+ tool_result.content = "<Tool returned an empty string>".into();
+ }
user_message
.content
- .push(language_model::MessageContent::ToolResult(
- tool_result.clone(),
- ));
+ .push(language_model::MessageContent::ToolResult(tool_result));
}
let mut messages = Vec::new();