Skip to content

Commit d1616f1

Browse files
committed
Description cleanup
1 parent 3389643 commit d1616f1

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/core/prompts/tools/native-tools/__tests__/read_file.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ describe("createReadFileTool", () => {
3434
expect(description).not.toContain("Example multiple files")
3535
})
3636

37+
it("should use singular 'Read a file' in base description when maxConcurrentFileReads is 1", () => {
38+
const tool = createReadFileTool({ maxConcurrentFileReads: 1 })
39+
const description = getFunctionDef(tool).description
40+
41+
expect(description).toMatch(/^Read a file/)
42+
expect(description).not.toContain("Read one or more files")
43+
})
44+
45+
it("should use plural 'Read one or more files' in base description when maxConcurrentFileReads is > 1", () => {
46+
const tool = createReadFileTool({ maxConcurrentFileReads: 5 })
47+
const description = getFunctionDef(tool).description
48+
49+
expect(description).toMatch(/^Read one or more files/)
50+
})
51+
3752
it("should not show multiple files example when maxConcurrentFileReads is 1", () => {
3853
const tool = createReadFileTool({ maxConcurrentFileReads: 1, partialReadsEnabled: true })
3954
const description = getFunctionDef(tool).description

src/core/prompts/tools/native-tools/read_file.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type OpenAI from "openai"
22

3-
const READ_FILE_BASE_DESCRIPTION = `Read one or more files and return their contents with line numbers for diffing or discussion.`
4-
53
const READ_FILE_SUPPORTS_NOTE = `Supports text extraction from PDF and DOCX files, but may not handle other binary files properly.`
64

75
/**
@@ -25,15 +23,13 @@ export function createReadFileTool(options: ReadFileToolOptions = {}): OpenAI.Ch
2523
const { partialReadsEnabled = true, maxConcurrentFileReads = 5 } = options
2624
const isMultipleReadsEnabled = maxConcurrentFileReads > 1
2725

28-
// Build concurrent reads limit message
29-
const concurrentReadsNote = isMultipleReadsEnabled
30-
? `IMPORTANT: You can read a maximum of ${maxConcurrentFileReads} files in a single request. If you need to read more files, use multiple sequential read_file requests. `
31-
: "IMPORTANT: Multiple file reads are currently disabled. You can only read one file at a time. "
26+
// Build description intro with concurrent reads limit message
27+
const descriptionIntro = isMultipleReadsEnabled
28+
? `Read one or more files and return their contents with line numbers for diffing or discussion. IMPORTANT: You can read a maximum of ${maxConcurrentFileReads} files in a single request. If you need to read more files, use multiple sequential read_file requests. `
29+
: "Read a file and return its contents with line numbers for diffing or discussion. IMPORTANT: Multiple file reads are currently disabled. You can only read one file at a time. "
3230

3331
const baseDescription =
34-
READ_FILE_BASE_DESCRIPTION +
35-
" " +
36-
concurrentReadsNote +
32+
descriptionIntro +
3733
"Structure: { files: [{ path: 'relative/path.ts'" +
3834
(partialReadsEnabled ? ", line_ranges: [[1, 50], [100, 150]]" : "") +
3935
" }] }. " +

0 commit comments

Comments
 (0)