Skip to content

Commit d6770e2

Browse files
committed
general agent: add context pruner, tweak prompts
1 parent ee4b07a commit d6770e2

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

agents/general-agent/general-agent.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const createGeneralAgent = (options: {
1919
displayName: isGpt5 ? 'GPT-5 Agent' : 'Opus Agent',
2020
spawnerPrompt:
2121
isGpt5 ?
22-
'A general-purpose, deep-thinking (and slow) agent that can be used to solve a wide range of problems. Use this to help you solve a specific problem that requires extended reasoning.'
23-
: 'A general-purpose capable agent that can be used to solve a wide range of problems. Use this to help you solve any problem.',
22+
'A general-purpose, deep-thinking (and slow) agent that can be used to solve a wide range of problems. Use this to help you solve a specific problem that requires extended reasoning. This agent has no context on the conversation history so you must provide all the relevant context (via the prompt or filePaths) for this agent to work well.'
23+
: 'A general-purpose capable agent that can be used to solve a wide range of problems. Use this to help you solve any problem. This agent has no context on the conversation history so you must provide all the relevant context (via the prompt or filePaths) for this agent to work well.',
2424
inputSchema: {
2525
prompt: {
2626
type: 'string',
@@ -50,6 +50,7 @@ export const createGeneralAgent = (options: {
5050
'directory-lister',
5151
'glob-matcher',
5252
'commander',
53+
'context-pruner',
5354
],
5455
toolNames: [
5556
'spawn_agents',
@@ -59,7 +60,7 @@ export const createGeneralAgent = (options: {
5960
'write_file',
6061
],
6162

62-
instructionsPrompt: `Use the spawn_agents tool to spawn agents to help you complete the user request. file-picker is really good at finding relevant files in the codebase and so you should spawn it if at all relevant. You should spawn multiple agents in parallel when possible to speed up the process. (e.g. spawn 3 file-pickers + 1 code-searcher + 1 researcher-web in one spawn_agents call or 3 commanders in one spawn_agents call). Read multiple files at once to speed up the process and get more context.`,
63+
instructionsPrompt: `Use the spawn_agents tool to spawn agents to help you complete the user request. If you need to find more information in the codebase, file-picker is really good at finding relevant files. You should spawn multiple agents in parallel when possible to speed up the process. (e.g. spawn 3 file-pickers + 1 code-searcher + 1 researcher-web in one spawn_agents call or 3 commanders in one spawn_agents call).`,
6364

6465
handleSteps: function* ({ params }) {
6566
const filePaths = params?.filePaths as string[] | undefined
@@ -71,8 +72,20 @@ export const createGeneralAgent = (options: {
7172
}
7273
}
7374

74-
// Allow multiple steps for extended reasoning
75-
yield 'STEP_ALL'
75+
while (true) {
76+
// Run context-pruner before each step
77+
yield {
78+
toolName: 'spawn_agent_inline',
79+
input: {
80+
agent_type: 'context-pruner',
81+
params: params ?? {},
82+
},
83+
includeToolCall: false,
84+
} as any
85+
86+
const { stepsComplete } = yield 'STEP'
87+
if (stepsComplete) break
88+
}
7689
},
7790
}
7891
}

0 commit comments

Comments
 (0)