Skip to content

Commit cd5a619

Browse files
committed
base2-gpt-5-high
1 parent 52075d6 commit cd5a619

File tree

8 files changed

+211
-120
lines changed

8 files changed

+211
-120
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { publisher } from '../../constants'
2+
import { base2 } from '../base2-factory'
3+
4+
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
5+
6+
const definition: SecretAgentDefinition = {
7+
id: 'base2-gpt-5-high',
8+
publisher,
9+
...base2('anthropic/claude-4-sonnet-20250522'),
10+
spawnableAgents: [
11+
'planner-gpt-5-high',
12+
'editor-gpt-5-high',
13+
'reviewer-gpt-5-high',
14+
'context-pruner',
15+
],
16+
}
17+
18+
export default definition
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import editor from '../editor'
2+
3+
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
4+
5+
const definition: SecretAgentDefinition = {
6+
...editor,
7+
id: 'editor-gpt-5-high',
8+
model: 'openai/gpt-5',
9+
reasoningOptions: {
10+
enabled: true,
11+
effort: 'high',
12+
exclude: true,
13+
},
14+
}
15+
16+
export default definition
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
2+
import { plannerFactory } from '../planner-factory'
3+
4+
const definition: SecretAgentDefinition = {
5+
id: 'planner-gpt-5-high',
6+
...plannerFactory('openai/gpt-5', 'thinker-gpt-5-high'),
7+
}
8+
9+
export default definition
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { reviewer } from '../../factory/reviewer'
2+
3+
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
4+
5+
const definition: SecretAgentDefinition = {
6+
...reviewer('openai/gpt-5'),
7+
id: 'reviewer-gpt-5-high',
8+
reasoningOptions: {
9+
effort: 'high',
10+
exclude: true,
11+
},
12+
}
13+
14+
export default definition
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { AgentDefinition } from '../../types/agent-definition'
2+
3+
import gpt5Thinker from '../../deep-thinking/gpt5-thinker'
4+
5+
const definition: AgentDefinition = {
6+
...gpt5Thinker,
7+
id: 'thinker-gpt-5-high',
8+
displayName: 'GPT-5 Deep Thinker',
9+
model: 'openai/gpt-5',
10+
reasoningOptions: {
11+
enabled: true,
12+
effort: 'high',
13+
exclude: true,
14+
},
15+
spawnerPrompt:
16+
'Spawn this agent when you need deep thinking on a topic using GPT-5 with high reasoning effort.',
17+
}
18+
export default definition

.agents/base2/planner-factory.ts

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { ModelName, ToolCall } from 'types/agent-definition'
2+
import { publisher } from '../constants'
3+
import {
4+
PLACEHOLDER,
5+
type SecretAgentDefinition,
6+
} from '../types/secret-agent-definition'
7+
8+
export const plannerFactory = (
9+
model: ModelName,
10+
thinkerAgent: string,
11+
): Omit<SecretAgentDefinition, 'id'> => ({
12+
publisher,
13+
14+
model,
15+
displayName: 'Peter Plan',
16+
spawnerPrompt:
17+
'Creates comprehensive plans by exploring the codebase and deep thinking',
18+
inputSchema: {
19+
prompt: {
20+
type: 'string',
21+
description: 'The coding task to plan for',
22+
},
23+
},
24+
outputMode: 'last_message',
25+
includeMessageHistory: true,
26+
toolNames: ['spawn_agents', 'end_turn'],
27+
spawnableAgents: ['file-explorer', 'researcher', thinkerAgent],
28+
29+
systemPrompt: `You are a strategic planner who creates comprehensive plans for coding tasks.
30+
You should spawn agents to help you gather information and think through the problem before creating your plan.
31+
${PLACEHOLDER.FILE_TREE_PROMPT}
32+
${PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS}`,
33+
34+
instructionsPrompt: `Create a comprehensive plan for the given coding task.
35+
36+
Process:
37+
1. First, spawn a file-explorer to understand the relevant codebase. You may also spawn a researcher to search the web for relevant information at the same time.
38+
2. Then spawn a thinker to analyze the best approach
39+
3. Finally, write out a plan that focuses on the high level approach to the task, with short excerpts of code/types that help
40+
41+
Your plan should be specific, actionable, and account for the current codebase structure.`,
42+
43+
handleSteps: function* ({ prompt }) {
44+
// Step 1: Spawn file-explorer and parse out the file paths
45+
const { agentState: stateAfterFileExplorer } = yield 'STEP'
46+
const { messageHistory } = stateAfterFileExplorer
47+
const lastAssistantMessageIndex =
48+
stateAfterFileExplorer.messageHistory.findLastIndex(
49+
(message) => message.role === 'assistant',
50+
)
51+
const toolResultMessage = messageHistory[lastAssistantMessageIndex + 1] ?? {
52+
content: '',
53+
}
54+
const filePaths = parseFilePathsFromToolResult(toolResultMessage.content)
55+
56+
// Step 2: Read the files
57+
yield {
58+
toolName: 'read_files',
59+
input: {
60+
paths: filePaths,
61+
},
62+
} satisfies ToolCall
63+
64+
// Step 3: Spawn deep-thinker to analyze approach
65+
const { toolResult: deepThinkerToolResult } = yield {
66+
toolName: 'spawn_agents',
67+
input: {
68+
agents: [
69+
{
70+
agent_type: thinkerAgent,
71+
prompt: `Create a clear implementation plan for the following task, with a focus on simplicity and making the minimal changes necessary for an awesome implementation. Prompt: ${prompt}`,
72+
},
73+
],
74+
},
75+
}
76+
77+
yield {
78+
toolName: 'set_output',
79+
input: {
80+
plan: deepThinkerToolResult,
81+
},
82+
}
83+
84+
function parseFilePathsFromToolResult(content: string): string[] {
85+
const filePaths: string[] = []
86+
87+
// Match file paths that look like valid paths (containing / and file extensions)
88+
const filePathRegex =
89+
/(?:^|\s|\*\s*)((?:[\w-]+\/)*[\w.-]+\.[a-zA-Z]{1,4})(?=\s|$|,|\.|:)/gm
90+
91+
let match
92+
while ((match = filePathRegex.exec(content)) !== null) {
93+
const filePath = match[1]
94+
// Filter out obvious false positives and ensure reasonable path structure
95+
if (
96+
filePath &&
97+
!filePath.startsWith('http') &&
98+
!filePath.includes('@') &&
99+
filePath.length > 3 &&
100+
filePath.split('/').length <= 10
101+
) {
102+
filePaths.push(filePath)
103+
}
104+
}
105+
106+
// Also look for backtick-quoted file paths
107+
const backtickPathRegex = /`([^`]+\.[a-zA-Z]{1,4})`/g
108+
while ((match = backtickPathRegex.exec(content)) !== null) {
109+
const filePath = match[1]
110+
if (
111+
filePath &&
112+
!filePath.startsWith('http') &&
113+
!filePath.includes('@')
114+
) {
115+
filePaths.push(filePath)
116+
}
117+
}
118+
119+
// Remove duplicates and return
120+
return [...new Set(filePaths)]
121+
}
122+
},
123+
})

.agents/base2/planner.ts

Lines changed: 5 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,9 @@
1-
import { ToolCall } from 'types/agent-definition'
2-
import { publisher } from '../constants'
3-
import {
4-
PLACEHOLDER,
5-
type SecretAgentDefinition,
6-
} from '../types/secret-agent-definition'
1+
import type { SecretAgentDefinition } from '../types/secret-agent-definition'
2+
import { plannerFactory } from './planner-factory'
73

8-
const planner: SecretAgentDefinition = {
4+
const definition: SecretAgentDefinition = {
95
id: 'planner',
10-
publisher,
11-
12-
model: 'google/gemini-2.5-pro',
13-
displayName: 'Peter Plan',
14-
spawnerPrompt:
15-
'Creates comprehensive plans by exploring the codebase and deep thinking',
16-
inputSchema: {
17-
prompt: {
18-
type: 'string',
19-
description: 'The coding task to plan for',
20-
},
21-
},
22-
outputMode: 'last_message',
23-
includeMessageHistory: true,
24-
toolNames: ['spawn_agents', 'end_turn'],
25-
spawnableAgents: ['file-explorer', 'researcher', 'gemini-thinker-high'],
26-
27-
systemPrompt: `You are a strategic planner who creates comprehensive plans for coding tasks.
28-
You should spawn agents to help you gather information and think through the problem before creating your plan.
29-
${PLACEHOLDER.FILE_TREE_PROMPT}
30-
${PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS}`,
31-
32-
instructionsPrompt: `Create a comprehensive plan for the given coding task.
33-
34-
Process:
35-
1. First, spawn a file-explorer to understand the relevant codebase. You may also spawn a researcher to search the web for relevant information at the same time.
36-
2. Then spawn a thinker to analyze the best approach
37-
3. Finally, write out a plan that focuses on the high level approach to the task, with short excerpts of code/types that help
38-
39-
Your plan should be specific, actionable, and account for the current codebase structure.`,
40-
41-
handleSteps: function* ({ prompt }) {
42-
// Step 1: Spawn file-explorer and parse out the file paths
43-
const { agentState: stateAfterFileExplorer } = yield 'STEP'
44-
const { messageHistory } = stateAfterFileExplorer
45-
const lastAssistantMessageIndex =
46-
stateAfterFileExplorer.messageHistory.findLastIndex(
47-
(message) => message.role === 'assistant',
48-
)
49-
const toolResultMessage = messageHistory[lastAssistantMessageIndex + 1] ?? {
50-
content: '',
51-
}
52-
const filePaths = parseFilePathsFromToolResult(toolResultMessage.content)
53-
54-
// Step 2: Read the files
55-
yield {
56-
toolName: 'read_files',
57-
input: {
58-
paths: filePaths,
59-
},
60-
} satisfies ToolCall
61-
62-
// Step 3: Spawn deep-thinker to analyze approach
63-
const { toolResult: deepThinkerToolResult } = yield {
64-
toolName: 'spawn_agents',
65-
input: {
66-
agents: [
67-
{
68-
agent_type: 'gemini-thinker-high',
69-
prompt: `Create a clear implementation plan for the following task, with a focus on simplicity and making the minimal changes necessary for an awesome implementation. Prompt: ${prompt}`,
70-
},
71-
],
72-
},
73-
}
74-
75-
yield {
76-
toolName: 'set_output',
77-
input: {
78-
plan: deepThinkerToolResult,
79-
},
80-
}
81-
82-
function parseFilePathsFromToolResult(content: string): string[] {
83-
const filePaths: string[] = []
84-
85-
// Match file paths that look like valid paths (containing / and file extensions)
86-
const filePathRegex =
87-
/(?:^|\s|\*\s*)((?:[\w-]+\/)*[\w.-]+\.[a-zA-Z]{1,4})(?=\s|$|,|\.|:)/gm
88-
89-
let match
90-
while ((match = filePathRegex.exec(content)) !== null) {
91-
const filePath = match[1]
92-
// Filter out obvious false positives and ensure reasonable path structure
93-
if (
94-
filePath &&
95-
!filePath.startsWith('http') &&
96-
!filePath.includes('@') &&
97-
filePath.length > 3 &&
98-
filePath.split('/').length <= 10
99-
) {
100-
filePaths.push(filePath)
101-
}
102-
}
103-
104-
// Also look for backtick-quoted file paths
105-
const backtickPathRegex = /`([^`]+\.[a-zA-Z]{1,4})`/g
106-
while ((match = backtickPathRegex.exec(content)) !== null) {
107-
const filePath = match[1]
108-
if (
109-
filePath &&
110-
!filePath.startsWith('http') &&
111-
!filePath.includes('@')
112-
) {
113-
filePaths.push(filePath)
114-
}
115-
}
116-
117-
// Remove duplicates and return
118-
return [...new Set(filePaths)]
119-
}
120-
},
6+
...plannerFactory('google/gemini-2.5-pro', 'gemini-thinker-high'),
1217
}
1228

123-
export default planner
9+
export default definition

backend/src/tools/handlers/tool/spawn-agents.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,14 @@ export const handleSpawnAgents = ((params: {
130130
userId,
131131
clientSessionId,
132132
onResponseChunk: (chunk: string | PrintModeEvent) => {
133-
if (agents.length === 1 && agents[0].agent_type === 'editor') {
133+
const agentsThatShouldStreamToClient = [
134+
'editor',
135+
'editor-gpt-5-high',
136+
]
137+
if (
138+
agents.length === 1 &&
139+
agentsThatShouldStreamToClient.includes(agents[0].agent_type)
140+
) {
134141
writeToClient(chunk)
135142
}
136143
if (typeof chunk !== 'string') {

0 commit comments

Comments
 (0)