Skip to content

Commit ab8227f

Browse files
committed
Create FILE_TREE_PROMPT_LARGE for use with haiku file-lister
1 parent 8d3e48b commit ab8227f

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

.agents/base2/base2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const createBase2: (
3535
includeMessageHistory: true,
3636
toolNames: ['spawn_agents', 'read_files', 'str_replace', 'write_file'],
3737
spawnableAgents: buildArray(
38-
'file-picker',
38+
'file-picker-max',
3939
'find-all-referencer',
4040
'researcher-web',
4141
'researcher-docs',
@@ -122,7 +122,7 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
122122
123123
The user asks you to implement a new feature. You respond in multiple steps:
124124
125-
1. Spawn file-pickers with different prompts to find relevant files; spawn a find-all-referencer to find more relevant files and answer questions about the codebase; spawn 1 docs researcher to find relevant docs.
125+
1. Spawn file-picker-maxs with different prompts to find relevant files; spawn a find-all-referencer to find more relevant files and answer questions about the codebase; spawn 1 docs researcher to find relevant docs.
126126
1a. Read all the relevant files using the read_files tool.
127127
2. Spawn one more file picker and one more find-all-referencer with different prompts to find relevant files.
128128
2a. Read all the relevant files using the read_files tool.
@@ -132,7 +132,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
132132
6. Fix any issues raised by the reviewer.
133133
7. Inform the user that you have completed the task in one sentence without a final summary.`,
134134

135-
stepPrompt: `Don't forget to spawn agents that could help, especially: the file-picker and find-all-referencer to get codebase context, the generate-plan agent to create a plan, and the reviewer to review changes.`,
135+
stepPrompt: `Don't forget to spawn agents that could help, especially: the file-picker-max and find-all-referencer to get codebase context, the generate-plan agent to create a plan, and the reviewer to review changes.`,
136136

137137
handleSteps: function* ({ prompt, params }) {
138138
let steps = 0

.agents/file-explorer/file-lister.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const definition: SecretAgentDefinition = {
2121
toolNames: [],
2222
spawnableAgents: [],
2323

24-
systemPrompt: `You are an expert at finding relevant files in a codebase and listing them out. ${PLACEHOLDER.FILE_TREE_PROMPT}`,
24+
systemPrompt: `You are an expert at finding relevant files in a codebase and listing them out. ${PLACEHOLDER.FILE_TREE_PROMPT_LARGE}`,
2525
instructionsPrompt: `Instructions:
2626
- Do not use any tools.
2727
- Do not write any analysis.

.agents/types/secret-agent-definition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const placeholderNames = [
2626
'CONFIG_SCHEMA',
2727
'FILE_TREE_PROMPT_SMALL',
2828
'FILE_TREE_PROMPT',
29+
'FILE_TREE_PROMPT_LARGE',
2930
'GIT_CHANGES_PROMPT',
3031
'INITIAL_AGENT_PROMPT',
3132
'KNOWLEDGE_FILES_CONTENTS',

backend/src/system-prompt/truncate-file-tree.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const truncateFileTreeBasedOnTokenBudget = (params: {
2929
const startTime = performance.now()
3030
const { fileTree, fileTokenScores } = fileContext
3131

32-
const treeWithTokens = printFileTreeWithTokens(fileTree, fileTokenScores)
32+
// NOTE: We are always filtering out files with "unimportant" extensions.
33+
const filteredTree = removeUnimportantFiles(fileTree)
34+
35+
const treeWithTokens = printFileTreeWithTokens(filteredTree, fileTokenScores)
3336
const treeWithTokensCount = countTokensJson(treeWithTokens)
3437

3538
if (treeWithTokensCount <= tokenBudget) {
@@ -40,8 +43,6 @@ export const truncateFileTreeBasedOnTokenBudget = (params: {
4043
}
4144
}
4245

43-
// If it doesn't fit, remove unimportant files
44-
const filteredTree = removeUnimportantFiles(fileTree)
4546
const printedFilteredTree = printFileTree(filteredTree)
4647
const filteredTreeNoTokensCount = countTokensJson(printedFilteredTree)
4748

backend/src/templates/strings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ export async function formatPrompt(
9494
mode: 'agent',
9595
logger,
9696
}),
97+
[PLACEHOLDER.FILE_TREE_PROMPT_LARGE]: () =>
98+
getProjectFileTreePrompt({
99+
fileContext,
100+
fileTreeTokenBudget: 190_000,
101+
mode: 'search',
102+
logger,
103+
}),
97104
[PLACEHOLDER.GIT_CHANGES_PROMPT]: () => getGitChangesPrompt(fileContext),
98105
[PLACEHOLDER.REMAINING_STEPS]: () => `${agentState.stepsRemaining!}`,
99106
[PLACEHOLDER.PROJECT_ROOT]: () => fileContext.projectRoot,

backend/src/templates/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const placeholderNames = [
1717
'CONFIG_SCHEMA',
1818
'FILE_TREE_PROMPT_SMALL',
1919
'FILE_TREE_PROMPT',
20+
'FILE_TREE_PROMPT_LARGE',
2021
'GIT_CHANGES_PROMPT',
2122
'INITIAL_AGENT_PROMPT',
2223
'KNOWLEDGE_FILES_CONTENTS',

0 commit comments

Comments
 (0)