ReadFileSchema is the OpenAI tool definition for read_file. The description nudges the model toward read_file over `cat` so it stops piping source through the shell just to look at it.
()
| 33 | if path == "" { |
| 34 | return "(empty path)" |
| 35 | } |
| 36 | // Refuse non-regular files up front: open(2) on a FIFO blocks forever |
| 37 | // waiting for a writer (leaking the tool goroutine past Ctrl+C, which |
| 38 | // cancels the turn but can't unblock the read), and an endless device file |
| 39 | // (/dev/zero) grows ReadFile's buffer without bound. Stat never blocks. |
| 40 | // The same Stat size-gates the whole-file read below (see maxFileBytes). |
| 41 | if info, err := os.Stat(path); err == nil { |
| 42 | if !info.Mode().IsRegular() && !info.IsDir() { |
| 43 | return fmt.Sprintf("(read error: %s is not a regular file)", path) |
| 44 | } |
| 45 | if info.Mode().IsRegular() && info.Size() > maxFileBytes { |
| 46 | return fmt.Sprintf("(too large: %s is %d bytes, over read_file's %dMB cap - read slices with bash instead: grep -n pattern, or sed -n '1,200p')", path, info.Size(), maxFileBytes>>20) |
| 47 | } |
| 48 | } |
| 49 | raw, err := os.ReadFile(path) |
| 50 | if err != nil { |
| 51 | return fmt.Sprintf("(read error: %v)", err) |
| 52 | } |
| 53 | lines := strings.Split(string(raw), "\n") |
| 54 | // A trailing newline splits into a final empty element that is not a line; |
| 55 | // counting it would report one line too many in every continuation note. |
| 56 | // Remember it so a window reaching the end restores it: read_file's |
no outgoing calls