Skip to content

Commit be3bda8

Browse files
committed
Remove XML-like <task>/<feedback> wrappers; process plain user input; update code/tests
1 parent 3a47c55 commit be3bda8

File tree

8 files changed

+22
-24
lines changed

8 files changed

+22
-24
lines changed

src/core/mentions/__tests__/processUserContentMentions.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe("processUserContentMentions", () => {
162162
})
163163
})
164164

165-
it("should not process text blocks without task or feedback tags", async () => {
165+
it("should process text blocks without special tags", async () => {
166166
const userContent = [
167167
{
168168
type: "text" as const,
@@ -177,8 +177,11 @@ describe("processUserContentMentions", () => {
177177
fileContextTracker: mockFileContextTracker,
178178
})
179179

180-
expect(parseMentions).not.toHaveBeenCalled()
181-
expect(result[0]).toEqual(userContent[0])
180+
expect(parseMentions).toHaveBeenCalled()
181+
expect(result[0]).toEqual({
182+
type: "text",
183+
text: "parsed: Regular text without special tags",
184+
})
182185
})
183186

184187
it("should process tool_result blocks with string content", async () => {
@@ -230,7 +233,7 @@ describe("processUserContentMentions", () => {
230233
fileContextTracker: mockFileContextTracker,
231234
})
232235

233-
expect(parseMentions).toHaveBeenCalledTimes(1)
236+
expect(parseMentions).toHaveBeenCalledTimes(2)
234237
expect(result[0]).toEqual({
235238
type: "tool_result",
236239
tool_use_id: "123",
@@ -241,7 +244,7 @@ describe("processUserContentMentions", () => {
241244
},
242245
{
243246
type: "text",
244-
text: "Regular text",
247+
text: "parsed: Regular text",
245248
},
246249
],
247250
})

src/core/mentions/processUserContentMentions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ export async function processUserContentMentions({
3939
// should parse mentions).
4040
return Promise.all(
4141
userContent.map(async (block) => {
42-
const shouldProcessMentions = (text: string) =>
43-
text.includes("<task>") ||
44-
text.includes("<feedback>") ||
45-
text.includes("<answer>") ||
46-
text.includes("<user_message>")
42+
const shouldProcessMentions = (_text: string) => true
4743

4844
if (block.type === "text") {
4945
if (shouldProcessMentions(block.text)) {

src/core/prompts/responses.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export const formatResponse = {
88
toolDenied: () => `The user denied this operation.`,
99

1010
toolDeniedWithFeedback: (feedback?: string) =>
11-
`The user denied this operation and provided the following feedback:\n<feedback>\n${feedback}\n</feedback>`,
11+
`The user denied this operation and provided the following feedback:\n${feedback}`,
1212

1313
toolApprovedWithFeedback: (feedback?: string) =>
14-
`The user approved this operation and provided the following context:\n<feedback>\n${feedback}\n</feedback>`,
14+
`The user approved this operation and provided the following context:\n${feedback}`,
1515

1616
toolError: (error?: string) => `The tool execution failed with the following error:\n<error>\n${error}\n</error>`,
1717

@@ -31,7 +31,7 @@ Otherwise, if you have not completed the task and do not need additional informa
3131
(This is an automated message, so do not respond to it conversationally.)`,
3232

3333
tooManyMistakes: (feedback?: string) =>
34-
`You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n<feedback>\n${feedback}\n</feedback>`,
34+
`You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n${feedback}`,
3535

3636
missingToolParameterError: (paramName: string) =>
3737
`Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${toolUseInstructionsReminder}`,

src/core/task/Task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
12221222
await this.initiateTaskLoop([
12231223
{
12241224
type: "text",
1225-
text: `<task>\n${task}\n</task>`,
1225+
text: task ?? "",
12261226
},
12271227
...imageBlocks,
12281228
])

src/core/task/__tests__/Task.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,9 @@ describe("Cline", () => {
918918
fileContextTracker: cline.fileContextTracker,
919919
})
920920

921-
// Regular text should not be processed
922-
expect((processedContent[0] as Anthropic.TextBlockParam).text).toBe(
921+
// Regular text should be processed
922+
expect((processedContent[0] as Anthropic.TextBlockParam).text).toContain("processed:")
923+
expect((processedContent[0] as Anthropic.TextBlockParam).text).toContain(
923924
"Regular text with 'some/path' (see below for file content)",
924925
)
925926

@@ -937,10 +938,11 @@ describe("Cline", () => {
937938
"<feedback>Check 'some/path' (see below for file content)</feedback>",
938939
)
939940

940-
// Regular tool result should not be processed
941+
// Regular tool result should be processed now
941942
const toolResult2 = processedContent[3] as Anthropic.ToolResultBlockParam
942943
const content2 = Array.isArray(toolResult2.content) ? toolResult2.content[0] : toolResult2.content
943-
expect((content2 as Anthropic.TextBlockParam).text).toBe(
944+
expect((content2 as Anthropic.TextBlockParam).text).toContain("processed:")
945+
expect((content2 as Anthropic.TextBlockParam).text).toContain(
944946
"Regular tool result with 'path' (see below for file content)",
945947
)
946948

src/core/tools/attemptCompletionTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export async function attemptCompletionTool(
125125

126126
toolResults.push({
127127
type: "text",
128-
text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n<feedback>\n${text}\n</feedback>`,
128+
text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n${text}`,
129129
})
130130

131131
toolResults.push(...formatResponse.imageBlocks(images))

src/core/tools/executeCommandTool.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ export async function executeCommand(
317317
[
318318
`Command is still running in terminal from '${terminal.getCurrentWorkingDirectory().toPosix()}'.`,
319319
result.length > 0 ? `Here's the output so far:\n${result}\n` : "\n",
320-
`The user provided the following feedback:`,
321-
`<feedback>\n${text}\n</feedback>`,
320+
`The user provided the following feedback:\n${text}`,
322321
].join("\n"),
323322
images,
324323
),

src/services/command/built-in-commands.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ const BUILT_IN_COMMANDS: Record<string, BuiltInCommandDefinition> = {
1111
init: {
1212
name: "init",
1313
description: "Analyze codebase and create concise AGENTS.md files for AI assistants",
14-
content: `<task>
15-
Please analyze this codebase and create an AGENTS.md file containing:
14+
content: `Please analyze this codebase and create an AGENTS.md file containing:
1615
1. Build/lint/test commands - especially for running a single test
1716
2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.
18-
</task>
1917
2018
<initialization>
2119
<purpose>

0 commit comments

Comments
 (0)