feat: prioritize batched reads for turn efficiency
ci / check (macos-latest) (push) Canceled after 0s
ci / check (ubuntu-latest) (push) Canceled after 0s
ci / check (windows-latest) (push) Canceled after 0s

Move read_many_files to core tool set so it is always offered. Strengthen
system-prompt guidance: read_file now redirects to read_many_files for
multiple files, read_many_files is framed as the primary reading tool with
an explicit batch range (2-20). Add a 'How to work' rule on read
efficiency, and a read-batching instruction in the deep agent variant.
861 tests pass; build clean.
This commit is contained in:
asepharyana
2026-09-11 19:06:04 +07:00
parent 7d77408a41
commit b0da909454
7 changed files with 61 additions and 6 deletions
+2 -1
View File
@@ -70,7 +70,8 @@ export const VARIANTS: AgentVariant[] = [
maxSteps: 80,
appendix:
'This task is hard or its cause is unclear. Form more than one hypothesis before you act and say which one ' +
'you are testing. Read enough of the code to be sure rather than guessing. Record findings with remember ' +
'you are testing. Read enough of the code to be sure rather than guessing — batch related files into a single ' +
'read_many_files call so the investigation stays cheap. Record findings with remember ' +
'so they survive compaction. Report what you verified and what you could not.',
},
{
+3 -2
View File
@@ -36,10 +36,10 @@ type ToolDoc = { name: string; line: string };
* a withheld tool teaches the model to attempt calls that cannot succeed.
*/
const TOOL_DOCS: ToolDoc[] = [
{ name: 'read_file', line: 'read before you edit. Never describe code you have not opened.' },
{ name: 'read_file', line: 'read one file before you edit. Never describe code you have not opened. When you need several files, batch them in one read_many_files call instead of N round trips.' },
{
name: 'read_many_files',
line: 'read several files in one round trip once you know which ones you need. An unreadable path is reported in place, not fatal.',
line: 'the primary reading tool: batch 2-20 files in one round trip once you know which you need. Per-file offset/limit; an unreadable path is reported in place, not fatal. Prefer this over repeated read_file calls.',
},
{
name: 'glob',
@@ -186,6 +186,7 @@ export function systemPrompt(parts: PromptParts): string {
const workflow = [
'- Read before you write. Ground every claim about the code in something you actually opened. Never describe code you have not read.',
'- Read efficiently: batch the files you need in one read_many_files call, use grep or outline before opening a large file, and never read the same file twice.',
'- Make the smallest change that solves the task. A bugfix diff contains only the bug; a feature diff contains only the feature.',
'- Match the existing style, libraries, and conventions. Sample a neighbouring file before inventing a pattern.',
approvalTools.length > 0
+1 -1
View File
@@ -56,7 +56,7 @@ export const readFileTool = withMeta({ set: 'core', mutating: false }, tool({
const MAX_BATCH_FILES = 20;
export const readManyFilesTool = withMeta({ set: 'edit-plus', mutating: false }, tool({
export const readManyFilesTool = withMeta({ set: 'core', mutating: false }, tool({
description:
'Read several text files in one call. Use it when you already know which files you need — one round trip ' +
'instead of one per file. Each file may set its own offset and limit. A path that cannot be read is reported ' +