Skip to content

Commit df6f385

Browse files
committed
selector: include suggested improvements!
1 parent 8a04ff4 commit df6f385

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ export const createBestOfNSelector2 = (options: {
7070
description:
7171
'An extremely short (1 sentence) description of why this implementation was chosen',
7272
},
73+
suggestedImprovements: {
74+
type: 'string',
75+
description:
76+
'A summary of suggested improvements from non-chosen implementations that could enhance the selected implementation. You can also include any new ideas you have to improve upon the selected implementation. Leave empty if no valuable improvements were found.',
77+
},
7378
},
74-
required: ['implementationId', 'reason'],
79+
required: ['implementationId', 'reason', 'suggestedImprovements'],
7580
},
7681

7782
instructionsPrompt: `As part of the best-of-n workflow of agents, you are the implementation selector agent.
@@ -85,7 +90,10 @@ The implementations are available in the params.implementations array, where eac
8590
- strategy: The strategy/approach used for this implementation
8691
- content: The unified diff showing what would change
8792
88-
Your task is to analyze each implementation's diff carefully, compare them against the original user requirements, and select the best implementation.
93+
Your task is to:
94+
1. Analyze each implementation's diff carefully, compare them against the original user requirements
95+
2. Select the best implementation
96+
3. Identify the best ideas/techniques from the NON-CHOSEN implementations that could improve the selected implementation
8997
9098
Evaluate each based on (in order of importance):
9199
- Correctness and completeness in fulfilling the user's request
@@ -95,6 +103,18 @@ Evaluate each based on (in order of importance):
95103
- Minimal changes to existing code (fewer files changed, fewer lines changed)
96104
- Clarity and readability
97105
106+
## Analyzing Non-Chosen Implementations
107+
108+
After selecting the best implementation, look at each non-chosen implementation and identify any valuable aspects that could enhance the selected implementation. These might include:
109+
- More elegant code patterns or abstractions
110+
- Simplified logic or reuse of existing code
111+
- Additional edge case handling
112+
- Better naming or organization
113+
- Useful comments or documentation
114+
- Additional features that align with the user's request
115+
116+
Only include improvements that are genuinely valuable and compatible with the selected implementation. If a non-chosen implementation has no useful improvements to offer, don't include it.
117+
98118
## User Request
99119
100120
For context, here is the original user request again:
@@ -108,10 +128,10 @@ Try to select an implementation that fulfills all the requirements in the user's
108128
109129
${
110130
isSonnet || isOpus
111-
? `Use <think> tags to write out your thoughts about the implementations as needed to pick the best implementation. IMPORTANT: You should think really really hard to make sure you pick the absolute best implementation! As soon as you know for sure which implementation is the best, you should output your choice.
131+
? `Use <think> tags to write out your thoughts about the implementations as needed to pick the best implementation. IMPORTANT: You should think really really hard to make sure you pick the absolute best implementation! Also analyze the non-chosen implementations for any valuable techniques or approaches that could improve the selected one.
112132
113-
Then, do not write any other explanations AT ALL. You should directly output a single tool call to set_output with the selected implementationId and short reason.`
114-
: `Output a single tool call to set_output with the selected implementationId. Do not write anything else.`
133+
Then, do not write any other explanations AT ALL. You should directly output a single tool call to set_output with the selected implementationId, short reason, and suggestedImprovements array.`
134+
: `Output a single tool call to set_output with the selected implementationId, reason, and suggestedImprovements. Do not write anything else.`
115135
}`,
116136
}
117137
}

.agents/editor/best-of-n/editor-multi-prompt2.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function createMultiPromptEditor(): Omit<SecretAgentDefinition, 'id'> {
1313
model: 'anthropic/claude-opus-4.5',
1414
displayName: 'Multi-Prompt Editor',
1515
spawnerPrompt:
16-
'Edits code by spawning multiple implementor agents with different strategy prompts, selects the best implementation, and applies the changes. Pass an array of short prompts specifying different implementation approaches. Make sure to read any files intended to be edited before spawning this agent.',
16+
'Edits code by spawning multiple implementor agents with different strategy prompts, selects the best implementation, and applies the changes. It also returns further suggested improvements which you should take seriously and act on. Pass as input an array of short prompts specifying different implementation approaches or strategies. Make sure to read any files intended to be edited before spawning this agent.',
1717

1818
includeMessageHistory: true,
1919
inheritParentSystemPrompt: true,
@@ -169,6 +169,7 @@ function* handleStepsMultiPrompt({
169169
value: {
170170
implementationId: string
171171
reason: string
172+
suggestedImprovements: string
172173
}
173174
}>(selectorResult)[0]
174175

@@ -226,12 +227,17 @@ function* handleStepsMultiPrompt({
226227
}
227228
}
228229

229-
// Set output with the applied results
230+
// Extract suggested improvements from selector output
231+
const selectorValue = selectorOutput.value ?? selectorOutput
232+
const suggestedImprovements = selectorValue.suggestedImprovements
233+
234+
// Set output with the applied results and suggested improvements
230235
yield {
231236
toolName: 'set_output',
232237
input: {
233238
chosenStrategy: chosenImplementation.strategy,
234239
toolResults: appliedToolResults,
240+
suggestedImprovements,
235241
},
236242
includeToolCall: false,
237243
} satisfies ToolCall<'set_output'>

0 commit comments

Comments
 (0)