Skip to content

Commit 4b96780

Browse files
committed
Refactor best-of-n agent files
1 parent c1b1b39 commit 4b96780

10 files changed

+117
-245
lines changed

.agents/base2/base2.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export const createBase2: (
1414
bestOfNFast?: boolean
1515
},
1616
) => Omit<SecretAgentDefinition, 'id'> = (mode, options) => {
17-
const { hasNoValidation = false, bestOfN = false, bestOfNFast = false } = options ?? {}
17+
const {
18+
hasNoValidation = false,
19+
bestOfN = false,
20+
bestOfNFast = false,
21+
} = options ?? {}
1822
const isFast = mode === 'fast'
1923
const isMax = mode === 'max'
2024

@@ -58,8 +62,8 @@ export const createBase2: (
5862
'researcher-web',
5963
'researcher-docs',
6064
'commander',
61-
bestOfN && 'base2-best-of-n-orchestrator',
62-
bestOfNFast && 'base2-best-of-n-fast-orchestrator',
65+
bestOfN && 'best-of-n-orchestrator',
66+
bestOfNFast && 'best-of-n-orchestrator-fast',
6367
isMax && 'base2-gpt-5-worker',
6468
'context-pruner',
6569
),
@@ -150,10 +154,11 @@ ${buildArray(
150154
isFast &&
151155
`- Use the write_todos tool to write out your step-by-step implementation plan.${hasNoValidation ? '' : ' You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc.'}`,
152156
bestOfN &&
153-
`- You must spawn the base2-best-of-n-orchestrator agent to implement the code changes, since it will generate multiple implementation proposals and select the best one, which the user wants you to do.`,
157+
`- You must spawn the best-of-n-orchestrator agent to implement the code changes, since it will generate multiple implementation proposals and select the best one, which the user wants you to do.`,
154158
bestOfNFast &&
155-
`- You must spawn the base2-best-of-n-fast-orchestrator agent to implement the code changes, since it will generate multiple implementation proposals and select the best one, which the user wants you to do.`,
156-
!bestOfN && !bestOfNFast &&
159+
`- You must spawn the best-of-n-orchestrator-fast agent to implement the code changes, since it will generate multiple implementation proposals and select the best one, which the user wants you to do.`,
160+
!bestOfN &&
161+
!bestOfNFast &&
157162
isFast &&
158163
`- Use the str_replace or write_file tool to make the changes. (Pause after making all the changes to see the tool results of your edits and double check they went through correctly.)`,
159164
isMax &&
@@ -162,7 +167,7 @@ ${buildArray(
162167
`- Test your changes${isFast ? ' briefly' : ''} by running appropriate validation commands for the project (e.g. typechecks, tests, lints, etc.). You may have to explore the project to find the appropriate commands. Don't skip this step!`,
163168
`- Inform the user that you have completed the task in one sentence or a few short bullet points. Don't create any markdown summary files, unless asked by the user. If you already finished the user request and said you're done, then don't say anything else.`,
164169
).join('\n')}`,
165-
stepPrompt: `${isMax ? "Keep working until the user's request is completely satisfied. " : ''}${bestOfN ? "You must spawn the base2-best-of-n-orchestrator agent to implement the code changes. Don't forget to do this! " : ''}After completing the user request, summarize your changes in a sentence or a few short bullet points. Do not create any summary markdown files or example documentation files, unless asked by the user. If you already summarized your changes, then end turn and don't say anything else.`,
170+
stepPrompt: `${isMax ? "Keep working until the user's request is completely satisfied. " : ''}${bestOfN ? "You must spawn the best-of-n-orchestrator agent to implement the code changes. Don't forget to do this! " : ''}After completing the user request, summarize your changes in a sentence or a few short bullet points. Do not create any summary markdown files or example documentation files, unless asked by the user. If you already summarized your changes, then end turn and don't say anything else.`,
166171
handleSteps: function* ({ params }) {
167172
let steps = 0
168173
while (true) {

.agents/base2/best-of-n/base2-best-of-n-editor.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

.agents/base2/best-of-n/base2-implementor-step-gpt-5.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

.agents/base2/best-of-n/base2-selector.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createBestOfNImplementor } from './best-of-n-implementor'
2+
3+
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
4+
5+
export default {
6+
...createBestOfNImplementor({ model: 'gpt-5' }),
7+
id: 'best-of-n-implementor-gpt-5',
8+
} satisfies SecretAgentDefinition

.agents/base2/best-of-n/base2-implementor-step.ts renamed to .agents/base2/best-of-n/best-of-n-implementor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
21
import { publisher } from '../../constants'
32

4-
export const createBase2ImplementorStep = (options: {
3+
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
4+
5+
export const createBestOfNImplementor = (options: {
56
model: 'sonnet' | 'gpt-5'
67
}): Omit<SecretAgentDefinition, 'id'> => {
78
const { model } = options
@@ -76,7 +77,7 @@ Write out your complete implementation now, formatting all changes as tool calls
7677
}
7778
}
7879
const definition = {
79-
...createBase2ImplementorStep({ model: 'sonnet' }),
80-
id: 'base2-implementor-step',
80+
...createBestOfNImplementor({ model: 'sonnet' }),
81+
id: 'best-of-n-implementor',
8182
}
8283
export default definition

.agents/base2/best-of-n/base2-best-of-n-fast-orchestrator.ts renamed to .agents/base2/best-of-n/best-of-n-orchestrator-fast.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { publisher } from '../../constants'
33
import { StepText, ToolCall } from 'types/agent-definition'
44

55
const definition: SecretAgentDefinition = {
6-
id: 'base2-best-of-n-fast-orchestrator',
6+
id: 'best-of-n-orchestrator-fast',
77
publisher,
88
model: 'anthropic/claude-sonnet-4.5',
99
displayName: 'Best-of-N Fast Implementation Orchestrator',
@@ -20,11 +20,7 @@ const definition: SecretAgentDefinition = {
2020
'set_messages',
2121
'set_output',
2222
],
23-
spawnableAgents: [
24-
'base2-implementor-step',
25-
'base2-implementor-step-gpt-5',
26-
'base2-selector-fast',
27-
],
23+
spawnableAgents: ['best-of-n-implementor', 'best-of-n-selector'],
2824

2925
inputSchema: {},
3026
outputMode: 'structured_output',
@@ -41,16 +37,15 @@ const definition: SecretAgentDefinition = {
4137
includeToolCall: false,
4238
} satisfies ToolCall<'set_messages'>
4339

44-
// Spawn 1 of each model for easy prompt caching
4540
const { toolResult: implementorsResult1 } = yield {
4641
toolName: 'spawn_agents',
4742
input: {
4843
agents: [
49-
{ agent_type: 'base2-implementor-step' },
50-
{ agent_type: 'base2-implementor-step' },
51-
{ agent_type: 'base2-implementor-step' },
52-
{ agent_type: 'base2-implementor-step' },
53-
{ agent_type: 'base2-implementor-step' },
44+
{ agent_type: 'best-of-n-implementor' },
45+
{ agent_type: 'best-of-n-implementor' },
46+
{ agent_type: 'best-of-n-implementor' },
47+
{ agent_type: 'best-of-n-implementor' },
48+
{ agent_type: 'best-of-n-implementor' },
5449
],
5550
},
5651
includeToolCall: false,
@@ -71,7 +66,7 @@ const definition: SecretAgentDefinition = {
7166
input: {
7267
agents: [
7368
{
74-
agent_type: 'base2-selector-fast',
69+
agent_type: 'best-of-n-selector',
7570
params: { implementations },
7671
},
7772
],
@@ -103,7 +98,7 @@ const definition: SecretAgentDefinition = {
10398
return
10499
}
105100

106-
// Spawn editor to apply the chosen implementation
101+
// Apply the chosen implementation using STEP_TEXT
107102
const { agentState: postEditsAgentState } = yield {
108103
type: 'STEP_TEXT',
109104
text: chosenImplementation.content,

0 commit comments

Comments
 (0)