Skip to content

Commit 0b38426

Browse files
authored
Move task to end of initial message to prevent it from being drowned out by environment details.
1 parent c66f685 commit 0b38426

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/core/Cline.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -441,24 +441,25 @@ export class Cline {
441441
// Task lifecycle
442442

443443
private async startTask(task?: string, images?: string[]): Promise<void> {
444-
// conversationHistory (for API) and clineMessages (for webview) need to be in sync
445-
// if the extension process were killed, then on restart the clineMessages might not be empty, so we need to set it to [] when we create a new Cline client (otherwise webview would show stale messages from previous session)
446-
this.clineMessages = []
447-
this.apiConversationHistory = []
448-
await this.providerRef.deref()?.postStateToWebview()
449-
450-
await this.say("text", task, images)
451-
this.isInitialized = true
444+
// conversationHistory (for API) and clineMessages (for webview) need to be in sync
445+
// if the extension process were killed, then on restart the clineMessages might not be empty, so we need to set it to [] when we create a new Cline client (otherwise webview would show stale messages from previous session)
446+
this.clineMessages = [];
447+
this.apiConversationHistory = [];
448+
await this.providerRef.deref()?.postStateToWebview();
449+
450+
await this.say("text", task, images);
451+
this.isInitialized = true;
452+
453+
let imageBlocks: Anthropic.ImageBlockParam[] = formatResponse.imageBlocks(images);
454+
await this.initiateTaskLoop([
455+
...imageBlocks,
456+
{
457+
type: "text",
458+
text: `<environment_details>Loading...</environment_details>\n\n<task>\n${task}\n</task>`,
459+
},
460+
]);
461+
}
452462

453-
let imageBlocks: Anthropic.ImageBlockParam[] = formatResponse.imageBlocks(images)
454-
await this.initiateTaskLoop([
455-
{
456-
type: "text",
457-
text: `<task>\n${task}\n</task>`,
458-
},
459-
...imageBlocks,
460-
])
461-
}
462463

463464
private async resumeTaskFromHistory() {
464465
const modifiedClineMessages = await this.getSavedClineMessages()

0 commit comments

Comments
 (0)