From da63e79a13529c3386d551f38c0ce9a70def1891 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Sun, 11 Jan 2026 19:56:23 +0530 Subject: [PATCH] Move read_file metadata to end of output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change read_file output format so the "šŸ” N lines read" appears as the last line after the file content, not before it. This keeps the output cleaner with just one metadata line at the end. --- crates/g3-core/src/tools/file_ops.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/crates/g3-core/src/tools/file_ops.rs b/crates/g3-core/src/tools/file_ops.rs index 56f1b5c..6e958be 100644 --- a/crates/g3-core/src/tools/file_ops.rs +++ b/crates/g3-core/src/tools/file_ops.rs @@ -104,11 +104,8 @@ pub async fn execute_read_file( let fallback_content = &content[fallback_start..]; let line_count = fallback_content.lines().count(); return Ok(format!( - "āš ļø Start position {} exceeds file length {}. Reading last {} chars instead.\n\ - šŸ” {} lines read (chars {}-{}):\n{}", - user_start, total_file_len, - total_file_len - fallback_start, - line_count, fallback_start, total_file_len, fallback_content + "{}\nšŸ” {} lines read (start {} exceeded length {}, showing last {} chars)", + fallback_content, line_count, user_start, total_file_len, total_file_len - fallback_start )); } @@ -164,18 +161,16 @@ pub async fn execute_read_file( // Token-aware truncation header let context_pct = (ctx.context_used_tokens as f32 / ctx.context_total_tokens as f32 * 100.0) as u32; Ok(format!( - "āš ļø TRUNCATED: chars {}-{} of {} (exceeds 20% context, at {}%)\n\ - šŸ” {} lines read:\n{}", - start_boundary, end_boundary, total_file_len, context_pct, - line_count, partial_content + "{}\nšŸ” {} lines read (truncated, chars {}-{} of {}, context {}%)", + partial_content, line_count, start_boundary, end_boundary, total_file_len, context_pct )) } else if start_char.is_some() || end_char.is_some() { Ok(format!( - "šŸ” {} lines read (chars {}-{}):\n{}", - line_count, start_boundary, end_boundary, partial_content + "{}\nšŸ” {} lines read (chars {}-{})", + partial_content, line_count, start_boundary, end_boundary )) } else { - Ok(format!("šŸ” {} lines read:\n{}", line_count, content)) + Ok(format!("{}\nšŸ” {} lines read", content, line_count)) } } Err(e) => Ok(format!("āŒ Failed to read file '{}': {}", path_str, e)),