Skip to content

Commit 854510b

Browse files
yuyutaotaoclaude
andauthored
chore(core): remove sub-goals feature from LLM planning (#1975)
* refactor(core): rename includeSubGoals to deepThink and remove sub-goal logic from planning prompt The model no longer needs to do task decomposition (sub-goals). This removes all goal/subGoal related logic from the planning prompt and its caller, keeping only the simpler instruction-based flow. https://claude.ai/code/session_016KXax4JyZu2MKkA2XjRX6t * fix(core): restore detailed thought tag guidance (without sub-goal references) Keep the full thought description telling the model what to consider (user's requirement, current state, next action) - just without the sub-goal related parts. https://claude.ai/code/session_016KXax4JyZu2MKkA2XjRX6t --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3425ebd commit 854510b

File tree

5 files changed

+48
-586
lines changed

5 files changed

+48
-586
lines changed

packages/core/src/ai-model/llm-planning.ts

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ import {
1818
} from '../common';
1919
import type { ConversationHistory } from './conversation-history';
2020
import { systemPromptToTaskPlanning } from './prompt/llm-planning';
21-
import {
22-
extractXMLTag,
23-
parseMarkFinishedIndexes,
24-
parseSubGoalsFromXML,
25-
} from './prompt/util';
21+
import { extractXMLTag } from './prompt/util';
2622
import {
2723
AIResponseParseError,
2824
callAI,
@@ -58,17 +54,6 @@ export function parseXMLPlanningResponse(
5854
finalizeMessage = completeGoalMatch[2]?.trim() || undefined;
5955
}
6056

61-
// Parse sub-goal related tags
62-
const updatePlanContent = extractXMLTag(xmlString, 'update-plan-content');
63-
const markSubGoalDone = extractXMLTag(xmlString, 'mark-sub-goal-done');
64-
65-
const updateSubGoals = updatePlanContent
66-
? parseSubGoalsFromXML(updatePlanContent)
67-
: undefined;
68-
const markFinishedIndexes = markSubGoalDone
69-
? parseMarkFinishedIndexes(markSubGoalDone)
70-
: undefined;
71-
7257
// Parse action
7358
let action: any = null;
7459
if (actionType && actionType.toLowerCase() !== 'null') {
@@ -98,8 +83,6 @@ export function parseXMLPlanningResponse(
9883
action,
9984
...(finalizeMessage !== undefined ? { finalizeMessage } : {}),
10085
...(finalizeSuccess !== undefined ? { finalizeSuccess } : {}),
101-
...(updateSubGoals?.length ? { updateSubGoals } : {}),
102-
...(markFinishedIndexes?.length ? { markFinishedIndexes } : {}),
10386
};
10487
}
10588

@@ -123,15 +106,12 @@ export async function plan(
123106

124107
const { modelFamily } = modelConfig;
125108

126-
// Only enable sub-goals when deepThink is true
127-
const includeSubGoals = opts.deepThink === true;
128-
129109
const systemPrompt = await systemPromptToTaskPlanning({
130110
actionSpace: opts.actionSpace,
131111
modelFamily,
132112
includeBbox: opts.includeBbox,
133113
includeThought: true, // always include thought
134-
includeSubGoals,
114+
deepThink: opts.deepThink === true,
135115
});
136116

137117
let imagePayload = screenshotBase64;
@@ -166,13 +146,11 @@ export async function plan(
166146

167147
let latestFeedbackMessage: ChatCompletionMessageParam;
168148

169-
// Build sub-goal status text to include in the message
170-
// In deepThink mode: show full sub-goals with logs
171-
// In non-deepThink mode: show historical execution logs
172-
const subGoalsText = includeSubGoals
173-
? conversationHistory.subGoalsToText()
174-
: conversationHistory.historicalLogsToText();
175-
const subGoalsSection = subGoalsText ? `\n\n${subGoalsText}` : '';
149+
// Build historical execution logs text to include in the message
150+
const historicalLogsText = conversationHistory.historicalLogsToText();
151+
const historicalLogsSection = historicalLogsText
152+
? `\n\n${historicalLogsText}`
153+
: '';
176154

177155
// Build memories text to include in the message
178156
const memoriesText = conversationHistory.memoriesToText();
@@ -184,7 +162,7 @@ export async function plan(
184162
content: [
185163
{
186164
type: 'text',
187-
text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.${memoriesSection}${subGoalsSection}`,
165+
text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.${memoriesSection}${historicalLogsSection}`,
188166
},
189167
{
190168
type: 'image_url',
@@ -203,7 +181,7 @@ export async function plan(
203181
content: [
204182
{
205183
type: 'text',
206-
text: `this is the latest screenshot${memoriesSection}${subGoalsSection}`,
184+
text: `this is the latest screenshot${memoriesSection}${historicalLogsSection}`,
207185
},
208186
{
209187
type: 'image_url',
@@ -256,10 +234,6 @@ export async function plan(
256234
if (planFromAI.finalizeSuccess !== undefined) {
257235
debug('task completed via <complete> tag, stop planning');
258236
shouldContinuePlanning = false;
259-
// Mark all sub-goals as finished when goal is completed (only when deepThink is enabled)
260-
if (includeSubGoals) {
261-
conversationHistory.markAllSubGoalsFinished();
262-
}
263237
}
264238

265239
const returnValue: PlanningAIResponse = {
@@ -301,25 +275,9 @@ export async function plan(
301275
});
302276
});
303277

304-
// Update sub-goals in conversation history based on response (only when deepThink is enabled)
305-
if (includeSubGoals) {
306-
if (planFromAI.updateSubGoals?.length) {
307-
conversationHistory.setSubGoals(planFromAI.updateSubGoals);
308-
}
309-
if (planFromAI.markFinishedIndexes?.length) {
310-
for (const index of planFromAI.markFinishedIndexes) {
311-
conversationHistory.markSubGoalFinished(index);
312-
}
313-
}
314-
// Append the planning log to the currently running sub-goal
315-
if (planFromAI.log) {
316-
conversationHistory.appendSubGoalLog(planFromAI.log);
317-
}
318-
} else {
319-
// In non-deepThink mode, accumulate logs as historical execution steps
320-
if (planFromAI.log) {
321-
conversationHistory.appendHistoricalLog(planFromAI.log);
322-
}
278+
// Accumulate logs as historical execution steps
279+
if (planFromAI.log) {
280+
conversationHistory.appendHistoricalLog(planFromAI.log);
323281
}
324282

325283
// Append memory to conversation history if present

0 commit comments

Comments
 (0)