Skip to content

Commit d3ebaa7

Browse files
committed
Simplify thinker-best-of-n. Tweak ui and prompts
1 parent 841d2a9 commit d3ebaa7

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

.agents/base2/base2.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
112112
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
113113
${buildArray(
114114
'- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.',
115+
isMax &&
116+
'- Spawn the thinker-best-of-n-gpt-5 after gathering context to solve complex problems.',
115117
`- Spawn a ${isMax ? 'editor-best-of-n-gpt-5' : 'editor-best-of-n'} agent to implement the changes after you have gathered all the context you need. You must spawn this agent for non-trivial changes, since it writes much better code than you would with the str_replace or write_file tools. Don't spawn the editor in parallel with context-gathering agents.`,
116118
'- Spawn commanders sequentially if the second command depends on the the first.',
117119
).join('\n ')}
@@ -247,6 +249,7 @@ function buildImplementationStepPrompt({
247249
`Keep working until the user's request is completely satisfied${!hasNoValidation ? ' and validated' : ''}, or until you require more information from the user.`,
248250
!isFast &&
249251
`You must spawn the ${isMax ? 'editor-best-of-n-gpt-5' : 'editor-best-of-n'} agent to implement code changes, since it will generate the best code changes.`,
252+
isMax && 'Spawn the thinker-best-of-n-gpt-5 to solve complex problems.',
250253
`After completing the user request, summarize your changes in a sentence${isFast ? '' : ' or a few short bullet points'}.${isSonnet ? " Don't create any summary markdown files or example documentation files, unless asked by the user." : ''}. Don't repeat yourself -- especially if you already summarized your changes then just end your turn.`,
251254
).join('\n')
252255
}

.agents/thinker/best-of-n/thinker-best-of-n.ts

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { publisher } from '../../constants'
22

33
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
4-
import type { AgentStepContext, ToolCall } from '../../types/agent-definition'
4+
import type {
5+
AgentStepContext,
6+
StepText,
7+
ToolCall,
8+
} from '../../types/agent-definition'
59

610
export function createThinkerBestOfN(
711
model: 'sonnet' | 'gpt-5',
@@ -18,7 +22,7 @@ export function createThinkerBestOfN(
1822
includeMessageHistory: true,
1923
inheritParentSystemPrompt: true,
2024

21-
toolNames: ['spawn_agents', 'set_messages', 'set_output'],
25+
toolNames: ['spawn_agents'],
2226
spawnableAgents: ['thinker-selector'],
2327

2428
inputSchema: {
@@ -37,19 +41,11 @@ export function createThinkerBestOfN(
3741
},
3842
},
3943
},
40-
outputMode: 'structured_output',
44+
outputMode: 'last_message',
4145

4246
instructionsPrompt: `You are one agent within the thinker-best-of-n. You were spawned to generate deep thinking about the user's request.
43-
44-
Your task is to think deeply, step by step, about the user request and how best to approach it.
45-
46-
Consider edge cases, potential issues, and alternative approaches. Also, propose reading files or spawning agents to get more context that would be helpful for solving the problem.
47-
48-
Come up with a list of insights that would help someone arrive at the best solution.
49-
50-
Try not to be too prescriptive or confident in one solution. Instead, give clear arguments and reasoning.
51-
52-
You must be extremely concise and to the point.
47+
48+
Answer the user's query to the best of your ability and be extremely concise and to the point.
5349
5450
**Important**: Do not use any tools! You are only thinking!`,
5551

@@ -64,7 +60,6 @@ function* handleSteps({
6460
}: AgentStepContext): ReturnType<
6561
NonNullable<SecretAgentDefinition['handleSteps']>
6662
> {
67-
const selectorAgent = 'thinker-selector'
6863
const n = Math.min(10, Math.max(1, (params?.n as number | undefined) ?? 5))
6964

7065
// Use GENERATE_N to generate n thinking outputs
@@ -86,7 +81,7 @@ function* handleSteps({
8681
input: {
8782
agents: [
8883
{
89-
agent_type: selectorAgent,
84+
agent_type: 'thinker-selector',
9085
params: { thoughts },
9186
},
9287
],
@@ -100,29 +95,25 @@ function* handleSteps({
10095

10196
if ('errorMessage' in selectorOutput) {
10297
yield {
103-
toolName: 'set_output',
104-
input: { error: selectorOutput.errorMessage },
105-
} satisfies ToolCall<'set_output'>
98+
type: 'STEP_TEXT',
99+
text: selectorOutput.errorMessage,
100+
} satisfies StepText
106101
return
107102
}
108103
const { thoughtId } = selectorOutput
109104
const chosenThought = thoughts.find((thought) => thought.id === thoughtId)
110105
if (!chosenThought) {
111106
yield {
112-
toolName: 'set_output',
113-
input: { error: 'Failed to find chosen thinking output.' },
114-
} satisfies ToolCall<'set_output'>
107+
type: 'STEP_TEXT',
108+
text: 'Failed to find chosen thinking output.',
109+
} satisfies StepText
115110
return
116111
}
117112

118-
// Set output with the chosen thinking
119113
yield {
120-
toolName: 'set_output',
121-
input: {
122-
response: chosenThought.content,
123-
},
124-
includeToolCall: false,
125-
} satisfies ToolCall<'set_output'>
114+
type: 'STEP_TEXT',
115+
text: chosenThought.content,
116+
} satisfies StepText
126117

127118
function extractSpawnResults<T>(
128119
results: any[] | undefined,

cli/src/components/message-block.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,14 @@ const AgentBranchWrapper = memo(
609609
onToggleCollapsed(agentBlock.agentId)
610610
}, [onToggleCollapsed, agentBlock.agentId])
611611

612-
// Create a status message for editor-best-of-n agent
612+
// Create a status message for editor-best-of-n and thinker-best-of-n agents
613613
const nParameterMessage =
614614
agentBlock.params?.n !== undefined &&
615-
agentBlock.agentType.includes('editor-best-of-n')
615+
(agentBlock.agentType.includes('editor-best-of-n')
616616
? `Generating ${agentBlock.params.n} implementations...`
617-
: undefined
617+
: agentBlock.agentType.includes('thinker-best-of-n')
618+
? `Generating ${agentBlock.params.n} deep thoughts...`
619+
: undefined)
618620

619621
return (
620622
<box key={keyPrefix} style={{ flexDirection: 'column', gap: 0 }}>

0 commit comments

Comments
 (0)