diff --git a/src/core/mentions/__tests__/processUserContentMentions.spec.ts b/src/core/mentions/__tests__/processUserContentMentions.spec.ts index ec2e08f92ae..b10edb0ddbb 100644 --- a/src/core/mentions/__tests__/processUserContentMentions.spec.ts +++ b/src/core/mentions/__tests__/processUserContentMentions.spec.ts @@ -34,7 +34,7 @@ describe("processUserContentMentions", () => { const userContent = [ { type: "text" as const, - text: "Read file with limit", + text: "Read file with limit", }, ] @@ -48,7 +48,7 @@ describe("processUserContentMentions", () => { }) expect(parseMentions).toHaveBeenCalledWith( - "Read file with limit", + "Read file with limit", "/test", mockUrlContentFetcher, mockFileContextTracker, @@ -64,7 +64,7 @@ describe("processUserContentMentions", () => { const userContent = [ { type: "text" as const, - text: "Read file without limit", + text: "Read file without limit", }, ] @@ -77,7 +77,7 @@ describe("processUserContentMentions", () => { }) expect(parseMentions).toHaveBeenCalledWith( - "Read file without limit", + "Read file without limit", "/test", mockUrlContentFetcher, mockFileContextTracker, @@ -93,7 +93,7 @@ describe("processUserContentMentions", () => { const userContent = [ { type: "text" as const, - text: "Read unlimited lines", + text: "Read unlimited lines", }, ] @@ -107,7 +107,7 @@ describe("processUserContentMentions", () => { }) expect(parseMentions).toHaveBeenCalledWith( - "Read unlimited lines", + "Read unlimited lines", "/test", mockUrlContentFetcher, mockFileContextTracker, @@ -121,11 +121,11 @@ describe("processUserContentMentions", () => { }) describe("content processing", () => { - it("should process text blocks with tags", async () => { + it("should process text blocks with tags", async () => { const userContent = [ { type: "text" as const, - text: "Do something", + text: "Do something", }, ] @@ -139,35 +139,12 @@ describe("processUserContentMentions", () => { expect(parseMentions).toHaveBeenCalled() expect(result.content[0]).toEqual({ type: "text", - text: "parsed: Do something", + text: "parsed: Do something", }) expect(result.mode).toBeUndefined() }) - it("should process text blocks with tags", async () => { - const userContent = [ - { - type: "text" as const, - text: "Fix this issue", - }, - ] - - const result = await processUserContentMentions({ - userContent, - cwd: "/test", - urlContentFetcher: mockUrlContentFetcher, - fileContextTracker: mockFileContextTracker, - }) - - expect(parseMentions).toHaveBeenCalled() - expect(result.content[0]).toEqual({ - type: "text", - text: "parsed: Fix this issue", - }) - expect(result.mode).toBeUndefined() - }) - - it("should not process text blocks without task or feedback tags", async () => { + it("should not process text blocks without user_message tags", async () => { const userContent = [ { type: "text" as const, @@ -192,7 +169,7 @@ describe("processUserContentMentions", () => { { type: "tool_result" as const, tool_use_id: "123", - content: "Tool feedback", + content: "Tool feedback", }, ] @@ -207,7 +184,7 @@ describe("processUserContentMentions", () => { expect(result.content[0]).toEqual({ type: "tool_result", tool_use_id: "123", - content: "parsed: Tool feedback", + content: "parsed: Tool feedback", }) expect(result.mode).toBeUndefined() }) @@ -220,7 +197,7 @@ describe("processUserContentMentions", () => { content: [ { type: "text" as const, - text: "Array task", + text: "Array task", }, { type: "text" as const, @@ -244,7 +221,7 @@ describe("processUserContentMentions", () => { content: [ { type: "text", - text: "parsed: Array task", + text: "parsed: Array task", }, { type: "text", @@ -259,7 +236,7 @@ describe("processUserContentMentions", () => { const userContent = [ { type: "text" as const, - text: "First task", + text: "First task", }, { type: "image" as const, @@ -272,7 +249,7 @@ describe("processUserContentMentions", () => { { type: "tool_result" as const, tool_use_id: "456", - content: "Feedback", + content: "Feedback", }, ] @@ -288,13 +265,13 @@ describe("processUserContentMentions", () => { expect(result.content).toHaveLength(3) expect(result.content[0]).toEqual({ type: "text", - text: "parsed: First task", + text: "parsed: First task", }) expect(result.content[1]).toEqual(userContent[1]) // Image block unchanged expect(result.content[2]).toEqual({ type: "tool_result", tool_use_id: "456", - content: "parsed: Feedback", + content: "parsed: Feedback", }) expect(result.mode).toBeUndefined() }) @@ -305,7 +282,7 @@ describe("processUserContentMentions", () => { const userContent = [ { type: "text" as const, - text: "Test default", + text: "Test default", }, ] @@ -317,7 +294,7 @@ describe("processUserContentMentions", () => { }) expect(parseMentions).toHaveBeenCalledWith( - "Test default", + "Test default", "/test", mockUrlContentFetcher, mockFileContextTracker, @@ -333,7 +310,7 @@ describe("processUserContentMentions", () => { const userContent = [ { type: "text" as const, - text: "Test explicit false", + text: "Test explicit false", }, ] @@ -346,7 +323,7 @@ describe("processUserContentMentions", () => { }) expect(parseMentions).toHaveBeenCalledWith( - "Test explicit false", + "Test explicit false", "/test", mockUrlContentFetcher, mockFileContextTracker, diff --git a/src/core/mentions/processUserContentMentions.ts b/src/core/mentions/processUserContentMentions.ts index 5ea78f4dc30..0793a0fba35 100644 --- a/src/core/mentions/processUserContentMentions.ts +++ b/src/core/mentions/processUserContentMentions.ts @@ -38,20 +38,13 @@ export async function processUserContentMentions({ // Process userContent array, which contains various block types: // TextBlockParam, ImageBlockParam, ToolUseBlockParam, and ToolResultBlockParam. // We need to apply parseMentions() to: - // 1. All TextBlockParam's text (first user message with task) + // 1. All TextBlockParam's text (first user message) // 2. ToolResultBlockParam's content/context text arrays if it contains - // "" (see formatToolDeniedFeedback, attemptCompletion, - // executeCommand, and consecutiveMistakeCount >= 3) or "" - // (see askFollowupQuestion), we place all user generated content in - // these tags so they can effectively be used as markers for when we - // should parse mentions). + // "" - we place all user generated content in this tag + // so it can effectively be used as a marker for when we should parse mentions. const content = await Promise.all( userContent.map(async (block) => { - const shouldProcessMentions = (text: string) => - text.includes("") || - text.includes("") || - text.includes("") || - text.includes("") + const shouldProcessMentions = (text: string) => text.includes("") if (block.type === "text") { if (shouldProcessMentions(block.text)) { diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts index ccb09e68e19..332e3c63b75 100644 --- a/src/core/prompts/responses.ts +++ b/src/core/prompts/responses.ts @@ -20,22 +20,20 @@ export const formatResponse = { if (isNativeProtocol(protocol ?? TOOL_PROTOCOL.XML)) { return JSON.stringify({ status: "denied", - message: "The user denied this operation and provided the following feedback", feedback: feedback, }) } - return `The user denied this operation and provided the following feedback:\n\n${feedback}\n` + return `The user denied this operation and responded with the message:\n\n${feedback}\n` }, toolApprovedWithFeedback: (feedback?: string, protocol?: ToolProtocol) => { if (isNativeProtocol(protocol ?? TOOL_PROTOCOL.XML)) { return JSON.stringify({ status: "approved", - message: "The user approved this operation and provided the following context", feedback: feedback, }) } - return `The user approved this operation and provided the following context:\n\n${feedback}\n` + return `The user approved this operation and responded with the message:\n\n${feedback}\n` }, toolError: (error?: string, protocol?: ToolProtocol) => { @@ -81,11 +79,10 @@ Otherwise, if you have not completed the task and do not need additional informa if (isNativeProtocol(protocol ?? TOOL_PROTOCOL.XML)) { return JSON.stringify({ status: "guidance", - message: "You seem to be having trouble proceeding", feedback: feedback, }) } - return `You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n\n${feedback}\n` + return `You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n\n${feedback}\n` }, missingToolParameterError: (paramName: string, protocol?: ToolProtocol) => { diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index b39c2f9b368..2b6dc88d0c2 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1866,7 +1866,7 @@ export class Task extends EventEmitter implements TaskLike { await this.initiateTaskLoop([ { type: "text", - text: `\n${task}\n`, + text: `\n${task}\n`, }, ...imageBlocks, ]).catch((error) => { @@ -2145,7 +2145,7 @@ export class Task extends EventEmitter implements TaskLike { if (responseText) { newUserContent.push({ type: "text", - text: `\n\nNew instructions for task continuation:\n\n${responseText}\n`, + text: `\n${responseText}\n`, }) } diff --git a/src/core/task/__tests__/Task.spec.ts b/src/core/task/__tests__/Task.spec.ts index 5b7346d49da..06aed372cda 100644 --- a/src/core/task/__tests__/Task.spec.ts +++ b/src/core/task/__tests__/Task.spec.ts @@ -875,7 +875,7 @@ describe("Cline", () => { }) describe("processUserContentMentions", () => { - it("should process mentions in task and feedback tags", async () => { + it("should process mentions in user_message tags", async () => { const [cline, task] = Task.create({ provider: mockProvider, apiConfiguration: mockApiConfig, @@ -889,7 +889,7 @@ describe("Cline", () => { } as const, { type: "text", - text: "Text with 'some/path' (see below for file content) in task tags", + text: "Text with 'some/path' (see below for file content) in user_message tags", } as const, { type: "tool_result", @@ -897,7 +897,7 @@ describe("Cline", () => { content: [ { type: "text", - text: "Check 'some/path' (see below for file content)", + text: "Check 'some/path' (see below for file content)", }, ], } as Anthropic.ToolResultBlockParam, @@ -925,18 +925,18 @@ describe("Cline", () => { "Regular text with 'some/path' (see below for file content)", ) - // Text within task tags should be processed + // Text within user_message tags should be processed expect((processedContent[1] as Anthropic.TextBlockParam).text).toContain("processed:") expect((processedContent[1] as Anthropic.TextBlockParam).text).toContain( - "Text with 'some/path' (see below for file content) in task tags", + "Text with 'some/path' (see below for file content) in user_message tags", ) - // Feedback tag content should be processed + // user_message tag content should be processed const toolResult1 = processedContent[2] as Anthropic.ToolResultBlockParam const content1 = Array.isArray(toolResult1.content) ? toolResult1.content[0] : toolResult1.content expect((content1 as Anthropic.TextBlockParam).text).toContain("processed:") expect((content1 as Anthropic.TextBlockParam).text).toContain( - "Check 'some/path' (see below for file content)", + "Check 'some/path' (see below for file content)", ) // Regular tool result should not be processed diff --git a/src/core/task/__tests__/task-tool-history.spec.ts b/src/core/task/__tests__/task-tool-history.spec.ts index 832e81c37b2..fc7f2fd1311 100644 --- a/src/core/task/__tests__/task-tool-history.spec.ts +++ b/src/core/task/__tests__/task-tool-history.spec.ts @@ -292,7 +292,7 @@ describe("Task Tool History Handling", () => { }, { type: "text" as const, - text: "Another message with tags", + text: "Another message with tags", }, { type: "tool_result" as const, diff --git a/src/core/tools/AskFollowupQuestionTool.ts b/src/core/tools/AskFollowupQuestionTool.ts index b75ca3b618e..69146a4c2e4 100644 --- a/src/core/tools/AskFollowupQuestionTool.ts +++ b/src/core/tools/AskFollowupQuestionTool.ts @@ -86,7 +86,7 @@ export class AskFollowupQuestionTool extends BaseTool<"ask_followup_question"> { task.consecutiveMistakeCount = 0 const { text, images } = await task.ask("followup", JSON.stringify(follow_up_json), false) await task.say("user_feedback", text ?? "", images) - pushToolResult(formatResponse.toolResult(`\n${text}\n`, images)) + pushToolResult(formatResponse.toolResult(`\n${text}\n`, images)) } catch (error) { await handleError("asking question", error as Error) } diff --git a/src/core/tools/AttemptCompletionTool.ts b/src/core/tools/AttemptCompletionTool.ts index 039036f829c..7e8e7816280 100644 --- a/src/core/tools/AttemptCompletionTool.ts +++ b/src/core/tools/AttemptCompletionTool.ts @@ -150,7 +150,7 @@ export class AttemptCompletionTool extends BaseTool<"attempt_completion"> { // User provided feedback - push tool result to continue the conversation await task.say("user_feedback", text ?? "", images) - const feedbackText = `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n\n${text}\n` + const feedbackText = `\n${text}\n` pushToolResult(formatResponse.toolResult(feedbackText, images)) } catch (error) { await handleError("inspecting site", error as Error) diff --git a/src/core/tools/ExecuteCommandTool.ts b/src/core/tools/ExecuteCommandTool.ts index 7feb71b0b89..52f47433068 100644 --- a/src/core/tools/ExecuteCommandTool.ts +++ b/src/core/tools/ExecuteCommandTool.ts @@ -340,8 +340,7 @@ export async function executeCommandInTerminal( [ `Command is still running in terminal from '${terminal.getCurrentWorkingDirectory().toPosix()}'.`, result.length > 0 ? `Here's the output so far:\n${result}\n` : "\n", - `The user provided the following feedback:`, - `\n${text}\n`, + `\n${text}\n`, ].join("\n"), images, ), diff --git a/src/core/tools/__tests__/readFileTool.spec.ts b/src/core/tools/__tests__/readFileTool.spec.ts index f178e38026c..0ab89c4f95d 100644 --- a/src/core/tools/__tests__/readFileTool.spec.ts +++ b/src/core/tools/__tests__/readFileTool.spec.ts @@ -95,11 +95,11 @@ vi.mock("../../prompts/responses", () => ({ toolDenied: vi.fn(() => "The user denied this operation."), toolDeniedWithFeedback: vi.fn( (feedback?: string) => - `The user denied this operation and provided the following feedback:\n\n${feedback}\n`, + `The user denied this operation and responded with the message:\n\n${feedback}\n`, ), toolApprovedWithFeedback: vi.fn( (feedback?: string) => - `The user approved this operation and provided the following context:\n\n${feedback}\n`, + `The user approved this operation and responded with the message:\n\n${feedback}\n`, ), rooIgnoreError: vi.fn( (path: string) =>