diff --git a/packages/types/src/experiment.ts b/packages/types/src/experiment.ts index 3890e92ed7..5424121d67 100644 --- a/packages/types/src/experiment.ts +++ b/packages/types/src/experiment.ts @@ -6,12 +6,7 @@ import type { Keys, Equals, AssertEqual } from "./type-fu.js" * ExperimentId */ -export const experimentIds = [ - "powerSteering", - "multiFileApplyDiff", - "preventFocusDisruption", - "assistantMessageParser", -] as const +export const experimentIds = ["powerSteering", "multiFileApplyDiff", "preventFocusDisruption"] as const export const experimentIdsSchema = z.enum(experimentIds) @@ -25,7 +20,6 @@ export const experimentsSchema = z.object({ powerSteering: z.boolean().optional(), multiFileApplyDiff: z.boolean().optional(), preventFocusDisruption: z.boolean().optional(), - assistantMessageParser: z.boolean().optional(), }) export type Experiments = z.infer diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 2a5b7afe29..9d57912040 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -80,7 +80,7 @@ import { ToolRepetitionDetector } from "../tools/ToolRepetitionDetector" import { FileContextTracker } from "../context-tracking/FileContextTracker" import { RooIgnoreController } from "../ignore/RooIgnoreController" import { RooProtectedController } from "../protect/RooProtectedController" -import { type AssistantMessageContent, presentAssistantMessage, parseAssistantMessage } from "../assistant-message" +import { type AssistantMessageContent, presentAssistantMessage } from "../assistant-message" import { AssistantMessageParser } from "../assistant-message/AssistantMessageParser" import { truncateConversationIfNeeded } from "../sliding-window" import { ClineProvider } from "../webview/ClineProvider" @@ -270,8 +270,7 @@ export class Task extends EventEmitter implements TaskLike { didRejectTool = false didAlreadyUseTool = false didCompleteReadingStream = false - assistantMessageParser?: AssistantMessageParser - isAssistantMessageParserEnabled = false + assistantMessageParser: AssistantMessageParser private lastUsedInstructions?: string private skipPrevResponseIdOnce: boolean = false @@ -355,6 +354,9 @@ export class Task extends EventEmitter implements TaskLike { TelemetryService.instance.captureTaskCreated(this.taskId) } + // Initialize the assistant message parser + this.assistantMessageParser = new AssistantMessageParser() + // Only set up diff strategy if diff is enabled. if (this.diffEnabled) { // Default to old strategy, will be updated if experiment is enabled. @@ -1751,9 +1753,7 @@ export class Task extends EventEmitter implements TaskLike { this.didAlreadyUseTool = false this.presentAssistantMessageLocked = false this.presentAssistantMessageHasPendingUpdates = false - if (this.assistantMessageParser) { - this.assistantMessageParser.reset() - } + this.assistantMessageParser.reset() await this.diffViewProvider.reset() @@ -1794,12 +1794,7 @@ export class Task extends EventEmitter implements TaskLike { // Parse raw assistant message chunk into content blocks. const prevLength = this.assistantMessageContent.length - if (this.isAssistantMessageParserEnabled && this.assistantMessageParser) { - this.assistantMessageContent = this.assistantMessageParser.processChunk(chunk.text) - } else { - // Use the old parsing method when experiment is disabled - this.assistantMessageContent = parseAssistantMessage(assistantMessage) - } + this.assistantMessageContent = this.assistantMessageParser.processChunk(chunk.text) if (this.assistantMessageContent.length > prevLength) { // New content we need to present, reset to @@ -2058,11 +2053,8 @@ export class Task extends EventEmitter implements TaskLike { // this.assistantMessageContent.forEach((e) => (e.partial = false)) // Now that the stream is complete, finalize any remaining partial content blocks - if (this.isAssistantMessageParserEnabled && this.assistantMessageParser) { - this.assistantMessageParser.finalizeContentBlocks() - this.assistantMessageContent = this.assistantMessageParser.getContentBlocks() - } - // When using old parser, no finalization needed - parsing already happened during streaming + this.assistantMessageParser.finalizeContentBlocks() + this.assistantMessageContent = this.assistantMessageParser.getContentBlocks() if (partialBlocks.length > 0) { // If there is content to update then it will complete and @@ -2081,9 +2073,7 @@ export class Task extends EventEmitter implements TaskLike { await this.providerRef.deref()?.postStateToWebview() // Reset parser after each complete conversation round - if (this.assistantMessageParser) { - this.assistantMessageParser.reset() - } + this.assistantMessageParser.reset() // Now add to apiConversationHistory. // Need to save assistant responses to file before proceeding to diff --git a/src/shared/__tests__/experiments.spec.ts b/src/shared/__tests__/experiments.spec.ts index 21401dc759..607c1e0b04 100644 --- a/src/shared/__tests__/experiments.spec.ts +++ b/src/shared/__tests__/experiments.spec.ts @@ -29,7 +29,6 @@ describe("experiments", () => { powerSteering: false, multiFileApplyDiff: false, preventFocusDisruption: false, - assistantMessageParser: false, } expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false) }) @@ -39,7 +38,6 @@ describe("experiments", () => { powerSteering: true, multiFileApplyDiff: false, preventFocusDisruption: false, - assistantMessageParser: false, } expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(true) }) @@ -49,7 +47,6 @@ describe("experiments", () => { powerSteering: false, multiFileApplyDiff: false, preventFocusDisruption: false, - assistantMessageParser: false, } expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false) }) diff --git a/src/shared/experiments.ts b/src/shared/experiments.ts index 4be89afa1a..548b55f68c 100644 --- a/src/shared/experiments.ts +++ b/src/shared/experiments.ts @@ -4,7 +4,6 @@ export const EXPERIMENT_IDS = { MULTI_FILE_APPLY_DIFF: "multiFileApplyDiff", POWER_STEERING: "powerSteering", PREVENT_FOCUS_DISRUPTION: "preventFocusDisruption", - ASSISTANT_MESSAGE_PARSER: "assistantMessageParser", } as const satisfies Record type _AssertExperimentIds = AssertEqual>> @@ -19,7 +18,6 @@ export const experimentConfigsMap: Record = { MULTI_FILE_APPLY_DIFF: { enabled: false }, POWER_STEERING: { enabled: false }, PREVENT_FOCUS_DISRUPTION: { enabled: false }, - ASSISTANT_MESSAGE_PARSER: { enabled: false }, } export const experimentDefault = Object.fromEntries( diff --git a/webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx b/webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx index b19f152457..36c197d3fc 100644 --- a/webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx +++ b/webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx @@ -229,7 +229,6 @@ describe("mergeExtensionState", () => { concurrentFileReads: true, multiFileApplyDiff: true, preventFocusDisruption: false, - assistantMessageParser: false, newTaskRequireTodos: false, } as Record, } @@ -248,7 +247,6 @@ describe("mergeExtensionState", () => { concurrentFileReads: true, multiFileApplyDiff: true, preventFocusDisruption: false, - assistantMessageParser: false, newTaskRequireTodos: false, }) })