Skip to content

Commit 5f8aa37

Browse files
committed
Add thinker
1 parent 13b247f commit 5f8aa37

File tree

3 files changed

+71
-27
lines changed

3 files changed

+71
-27
lines changed

.agents/base2/base2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function createBase2(
6464
'researcher-web',
6565
'researcher-docs',
6666
isLite ? 'commander-lite' : 'commander',
67+
isDefault && 'thinker',
6768
isLite && 'editor-gpt-5',
6869
isDefault && 'editor',
6970
isMax && 'editor-best-of-n-max',

.agents/thinker/thinker.ts

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,76 @@ import type { SecretAgentDefinition } from '../types/secret-agent-definition'
55
const definition: SecretAgentDefinition = {
66
id: 'thinker',
77
publisher,
8-
model: 'anthropic/claude-sonnet-4.5',
8+
model: 'anthropic/claude-opus-4.5',
99
displayName: 'Theo the Theorizer',
1010
spawnerPrompt:
11-
'Does deep thinking given the current messages and a specific prompt to focus on. Use this to help you solve a specific problem.',
11+
'Does deep thinking given the current conversation history and a specific prompt to focus on. Use this to help you solve a specific problem. It is better to gather any relevant context before spawning this agent.',
1212
inputSchema: {
1313
prompt: {
1414
type: 'string',
1515
description: 'The problem you are trying to solve',
1616
},
1717
},
18-
outputMode: 'last_message',
18+
outputSchema: {
19+
type: 'object',
20+
properties: {
21+
message: {
22+
type: 'string',
23+
description: "The response to the user's request",
24+
},
25+
},
26+
},
27+
outputMode: 'structured_output',
1928
inheritParentSystemPrompt: true,
2029
includeMessageHistory: true,
2130
spawnableAgents: [],
31+
toolNames: [],
2232

2333
instructionsPrompt: `
24-
Think deeply, step by step, about the user request and how best to approach it.
34+
You are a thinker agent. Use the <think> tag to think deeply about the user request.
2535
26-
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.
36+
When satisfied, write out a brief response to the user's request. The parent agent will see your response -- no need to call any tools. DO NOT call the set_output tool, as that will be done for you.
37+
`.trim(),
2738

28-
Come up with a list of insights that would help someone arrive at the best solution.
39+
handleSteps: function* () {
40+
const { agentState } = yield 'STEP'
2941

30-
Try not to be too prescriptive or confident in one solution. Instead, give clear arguments and reasoning.
42+
// Find the last assistant message
43+
const lastAssistantMessage = [...agentState.messageHistory]
44+
.reverse()
45+
.find((m) => m.role === 'assistant')
3146

32-
You must be extremely concise and to the point.
47+
if (!lastAssistantMessage) {
48+
yield {
49+
toolName: 'set_output',
50+
input: { message: 'No response generated' },
51+
}
52+
return
53+
}
3354

34-
**Important**: Do not use any tools! You are only thinking!
35-
`.trim(),
55+
// Extract text content from the assistant message
56+
const content = lastAssistantMessage.content
57+
let textContent = ''
58+
if (typeof content === 'string') {
59+
textContent = content
60+
} else if (Array.isArray(content)) {
61+
textContent = content
62+
.filter((part) => part.type === 'text')
63+
.map((part) => part.text)
64+
.join('')
65+
}
66+
67+
// Remove text within <think> tags (including the tags themselves)
68+
const cleanedText = textContent
69+
.replace(/<think>[\s\S]*?<\/think>/g, '')
70+
.trim()
71+
72+
yield {
73+
toolName: 'set_output',
74+
input: { message: cleanedText },
75+
includeToolCall: false,
76+
}
77+
},
3678
}
3779

3880
export default definition

common/src/types/dynamic-agent-template.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,23 +227,24 @@ export const DynamicAgentTemplateSchema = DynamicAgentDefinitionSchema.extend({
227227
path: ['outputMode'],
228228
},
229229
)
230-
.refine(
231-
(data) => {
232-
// If outputMode is 'structured_output', 'set_output' tool must be included
233-
if (
234-
data.outputMode === 'structured_output' &&
235-
!data.toolNames.includes('set_output')
236-
) {
237-
return false
238-
}
239-
return true
240-
},
241-
{
242-
message:
243-
"outputMode 'structured_output' requires the 'set_output' tool. Add 'set_output' to toolNames.",
244-
path: ['toolNames'],
245-
},
246-
)
230+
// Note(James): Disabled so that handleSteps could use set_output while the llm does not see or have access to the set_output tool.
231+
// .refine(
232+
// (data) => {
233+
// // If outputMode is 'structured_output', 'set_output' tool must be included
234+
// if (
235+
// data.outputMode === 'structured_output' &&
236+
// !data.toolNames.includes('set_output')
237+
// ) {
238+
// return false
239+
// }
240+
// return true
241+
// },
242+
// {
243+
// message:
244+
// "outputMode 'structured_output' requires the 'set_output' tool. Add 'set_output' to toolNames.",
245+
// path: ['toolNames'],
246+
// },
247+
// )
247248
// Note(James): Disabled so that a parent agent can have set_output tool and 'last_message' outputMode while its subagents use 'structured_output'. (The set_output tool must be included in parent to preserver prompt caching.)
248249
// .refine(
249250
// (data) => {

0 commit comments

Comments
 (0)