From 9e38c45a9bc0c4db5d22c16b3021f00a213d3e88 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Fri, 4 Apr 2025 11:40:05 +0200 Subject: [PATCH] agent: Show which lines were read when using `read_file` tool (#28077) This makes sure that we specify which lines the agent actually read, avoids confusing scenarios such as: Screenshot 2025-04-04 at 10 22 10 Here the agent starts out by actually only reading a certain amount of lines when the first tool call happens, then it does a second tool call to read the whole file. To the user this looks like to identical tool calls. Now: image image image Release Notes: - N/A --- crates/assistant_tools/src/read_file_tool.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/assistant_tools/src/read_file_tool.rs b/crates/assistant_tools/src/read_file_tool.rs index 17d7803d79..b78d8d82d6 100644 --- a/crates/assistant_tools/src/read_file_tool.rs +++ b/crates/assistant_tools/src/read_file_tool.rs @@ -67,7 +67,11 @@ impl Tool for ReadFileTool { match serde_json::from_value::(input.clone()) { Ok(input) => { let path = MarkdownString::inline_code(&input.path.display().to_string()); - format!("Read file {path}") + match (input.start_line, input.end_line) { + (Some(start), None) => format!("Read file {path} (from line {start})"), + (Some(start), Some(end)) => format!("Read file {path} (lines {start}-{end})"), + _ => format!("Read file {path}"), + } } Err(_) => "Read file".to_string(), }