@@ -197,7 +197,6 @@ func isBlockedFile(expandedPath string) (bool, string) {
197197 return false , ""
198198}
199199
200-
201200func readTextFileCallback (input any , toolUseData * uctypes.UIMessageDataToolUse ) (any , error ) {
202201 const ReadLimit = 1024 * 1024 * 1024
203202
@@ -283,7 +282,7 @@ func readTextFileCallback(input any, toolUseData *uctypes.UIMessageDataToolUse)
283282 "modified_time" : modTime .UTC ().Format (time .RFC3339 ),
284283 "mode" : fileInfo .Mode ().String (),
285284 }
286- if stopReason != "" {
285+ if stopReason == "read_limit" || stopReason == StopReasonMaxBytes {
287286 result ["truncated" ] = stopReason
288287 }
289288
@@ -319,20 +318,20 @@ func GetReadTextFileToolDefinition() uctypes.ToolDefinition {
319318 "count" : map [string ]any {
320319 "type" : "integer" ,
321320 "minimum" : 1 ,
322- "default" : 100 ,
321+ "default" : ReadFileDefaultLineCount ,
323322 "description" : "Number of lines to return" ,
324323 },
325324 "max_bytes" : map [string ]any {
326325 "type" : "integer" ,
327326 "minimum" : 1 ,
328- "default" : 51200 ,
327+ "default" : ReadFileDefaultMaxBytes ,
329328 "description" : "Maximum bytes to return. If the result exceeds this, it will be truncated at line boundaries" ,
330329 },
331330 },
332331 "required" : []string {"filename" },
333332 "additionalProperties" : false ,
334333 },
335- ToolInputDesc : func (input any ) string {
334+ ToolCallDesc : func (input any , output any , toolUseData * uctypes. UIMessageDataToolUse ) string {
336335 parsed , err := parseReadTextFileInput (input )
337336 if err != nil {
338337 return fmt .Sprintf ("error parsing input: %v" , err )
@@ -342,10 +341,24 @@ func GetReadTextFileToolDefinition() uctypes.ToolDefinition {
342341 offset := * parsed .Offset
343342 count := * parsed .Count
344343
344+ readFullFile := false
345+ if output != nil {
346+ if outputMap , ok := output .(map [string ]any ); ok {
347+ _ , wasTruncated := outputMap ["truncated" ]
348+ readFullFile = ! wasTruncated
349+ }
350+ }
351+
345352 if origin == "start" && offset == 0 {
353+ if readFullFile {
354+ return fmt .Sprintf ("reading %q (entire file)" , parsed .Filename )
355+ }
346356 return fmt .Sprintf ("reading %q (first %d lines)" , parsed .Filename , count )
347357 }
348358 if origin == "end" && offset == 0 {
359+ if readFullFile {
360+ return fmt .Sprintf ("reading %q (entire file)" , parsed .Filename )
361+ }
349362 return fmt .Sprintf ("reading %q (last %d lines)" , parsed .Filename , count )
350363 }
351364 if origin == "end" {
0 commit comments