Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Fix unnecessary "tool result too long" (#30798)
Oleksiy Syvokoncc3a28a8e80a
diff --git a/crates/agent/src/tool_use.rs b/crates/agent/src/tool_use.rsindex 7808ffb145a..c26968949f1 100644--- a/crates/agent/src/tool_use.rs+++ b/crates/agent/src/tool_use.rs@@ -425,16 +425,17 @@ impl ToolUseState {let content = match tool_result {ToolResultContent::Text(text) => {- let truncated = truncate_lines_to_byte_limit(&text, tool_output_limit);-- LanguageModelToolResultContent::Text(+ let text = if text.len() < tool_output_limit {+ text+ } else {+ let truncated = truncate_lines_to_byte_limit(&text, tool_output_limit);format!("Tool result too long. The first {} bytes:\n\n{}",truncated.len(),truncated)- .into(),- )+ };+ LanguageModelToolResultContent::Text(text.into())}ToolResultContent::Image(language_model_image) => {if language_model_image.estimate_tokens() < tool_output_limit {