Skip to content

Commit 095e2ec

Browse files
committed
Fix gpt-5-high planner
1 parent 14ec354 commit 095e2ec

File tree

3 files changed

+95
-5
lines changed

3 files changed

+95
-5
lines changed
Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,100 @@
11
import type { SecretAgentDefinition } from '../../types/secret-agent-definition'
22
import { plannerFactory } from '../planner-factory'
3+
import { ToolCall } from 'types/agent-definition'
34

45
const definition: SecretAgentDefinition = {
56
id: 'planner-gpt-5-high',
6-
...plannerFactory('openai/gpt-5', 'thinker-gpt-5-high'),
7+
8+
...plannerFactory('openai/gpt-5'),
9+
10+
reasoningOptions: {
11+
enabled: true,
12+
effort: 'high',
13+
exclude: true,
14+
},
15+
16+
spawnableAgents: ['file-explorer', 'researcher', 'thinker-gpt-5-high'],
17+
18+
handleSteps: function* ({ prompt }) {
19+
// Step 1: Spawn file-explorer and parse out the file paths
20+
const { agentState: stateAfterFileExplorer } = yield 'STEP'
21+
const { messageHistory } = stateAfterFileExplorer
22+
const lastAssistantMessageIndex =
23+
stateAfterFileExplorer.messageHistory.findLastIndex(
24+
(message) => message.role === 'assistant',
25+
)
26+
const toolResultMessage = messageHistory[lastAssistantMessageIndex + 1] ?? {
27+
content: '',
28+
}
29+
const filePaths = parseFilePathsFromToolResult(toolResultMessage.content)
30+
31+
// Step 2: Read the files
32+
yield {
33+
toolName: 'read_files',
34+
input: {
35+
paths: filePaths,
36+
},
37+
} satisfies ToolCall
38+
39+
// Step 3: Spawn deep-thinker to analyze approach
40+
const { toolResult: deepThinkerToolResult } = yield {
41+
toolName: 'spawn_agents',
42+
input: {
43+
agents: [
44+
{
45+
agent_type: 'gemini-thinker-high',
46+
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}`,
47+
},
48+
],
49+
},
50+
}
51+
52+
yield {
53+
toolName: 'set_output',
54+
input: {
55+
plan: deepThinkerToolResult,
56+
},
57+
}
58+
59+
function parseFilePathsFromToolResult(content: string): string[] {
60+
const filePaths: string[] = []
61+
62+
// Match file paths that look like valid paths (containing / and file extensions)
63+
const filePathRegex =
64+
/(?:^|\s|\*\s*)((?:[\w-]+\/)*[\w.-]+\.[a-zA-Z]{1,4})(?=\s|$|,|\.|:)/gm
65+
66+
let match
67+
while ((match = filePathRegex.exec(content)) !== null) {
68+
const filePath = match[1]
69+
// Filter out obvious false positives and ensure reasonable path structure
70+
if (
71+
filePath &&
72+
!filePath.startsWith('http') &&
73+
!filePath.includes('@') &&
74+
filePath.length > 3 &&
75+
filePath.split('/').length <= 10
76+
) {
77+
filePaths.push(filePath)
78+
}
79+
}
80+
81+
// Also look for backtick-quoted file paths
82+
const backtickPathRegex = /`([^`]+\.[a-zA-Z]{1,4})`/g
83+
while ((match = backtickPathRegex.exec(content)) !== null) {
84+
const filePath = match[1]
85+
if (
86+
filePath &&
87+
!filePath.startsWith('http') &&
88+
!filePath.includes('@')
89+
) {
90+
filePaths.push(filePath)
91+
}
92+
}
93+
94+
// Remove duplicates and return
95+
return [...new Set(filePaths)]
96+
}
97+
},
798
}
899

9100
export default definition

.agents/base2/planner-factory.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77

88
export const plannerFactory = (
99
model: ModelName,
10-
thinkerAgent: string,
1110
): Omit<SecretAgentDefinition, 'id'> => ({
1211
publisher,
1312

@@ -24,7 +23,7 @@ export const plannerFactory = (
2423
outputMode: 'last_message',
2524
includeMessageHistory: true,
2625
toolNames: ['spawn_agents', 'end_turn'],
27-
spawnableAgents: ['file-explorer', 'researcher', thinkerAgent],
26+
spawnableAgents: ['file-explorer', 'researcher', 'gemini-thinker-high'],
2827

2928
systemPrompt: `You are a strategic planner who creates comprehensive plans for coding tasks.
3029
You should spawn agents to help you gather information and think through the problem before creating your plan.
@@ -67,7 +66,7 @@ Your plan should be specific, actionable, and account for the current codebase s
6766
input: {
6867
agents: [
6968
{
70-
agent_type: thinkerAgent,
69+
agent_type: 'gemini-thinker-high',
7170
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}`,
7271
},
7372
],

.agents/base2/planner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { plannerFactory } from './planner-factory'
33

44
const definition: SecretAgentDefinition = {
55
id: 'planner',
6-
...plannerFactory('google/gemini-2.5-pro', 'gemini-thinker-high'),
6+
...plannerFactory('google/gemini-2.5-pro'),
77
}
88

99
export default definition

0 commit comments

Comments
 (0)