Skip to content

Commit 1ff8a56

Browse files
authored
Fix how custom instructions are loaded into the API request (RooCodeInc#3638)p
1 parent bcc4526 commit 1ff8a56

File tree

4 files changed

+4
-73
lines changed

4 files changed

+4
-73
lines changed

src/core/task/Task.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export type ClineEvents = {
100100
export type TaskOptions = {
101101
provider: ClineProvider
102102
apiConfiguration: ProviderSettings
103-
customInstructions?: string
104103
enableDiff?: boolean
105104
enableCheckpoints?: boolean
106105
fuzzyMatchThreshold?: number
@@ -134,7 +133,6 @@ export class Task extends EventEmitter<ClineEvents> {
134133
isPaused: boolean = false
135134
pausedModeSlug: string = defaultModeSlug
136135
private pauseInterval: NodeJS.Timeout | undefined
137-
customInstructions?: string
138136

139137
// API
140138
readonly apiConfiguration: ProviderSettings
@@ -194,7 +192,6 @@ export class Task extends EventEmitter<ClineEvents> {
194192
constructor({
195193
provider,
196194
apiConfiguration,
197-
customInstructions,
198195
enableDiff = false,
199196
enableCheckpoints = true,
200197
fuzzyMatchThreshold = 1.0,
@@ -234,7 +231,6 @@ export class Task extends EventEmitter<ClineEvents> {
234231

235232
this.urlContentFetcher = new UrlContentFetcher(provider.context)
236233
this.browserSession = new BrowserSession(provider.context)
237-
this.customInstructions = customInstructions
238234
this.diffEnabled = enableDiff
239235
this.fuzzyMatchThreshold = fuzzyMatchThreshold
240236
this.consecutiveMistakeLimit = consecutiveMistakeLimit
@@ -1417,6 +1413,7 @@ export class Task extends EventEmitter<ClineEvents> {
14171413
browserViewportSize,
14181414
mode,
14191415
customModePrompts,
1416+
customInstructions,
14201417
experiments,
14211418
enableMcpServerCreation,
14221419
browserToolEnabled,
@@ -1442,7 +1439,7 @@ export class Task extends EventEmitter<ClineEvents> {
14421439
mode,
14431440
customModePrompts,
14441441
customModes,
1445-
this.customInstructions,
1442+
customInstructions,
14461443
this.diffEnabled,
14471444
experiments,
14481445
enableMcpServerCreation,

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,21 +275,18 @@ describe("Cline", () => {
275275
const cline = new Task({
276276
provider: mockProvider,
277277
apiConfiguration: mockApiConfig,
278-
customInstructions: "custom instructions",
279278
fuzzyMatchThreshold: 0.95,
280279
task: "test task",
281280
startTask: false,
282281
})
283282

284-
expect(cline.customInstructions).toBe("custom instructions")
285283
expect(cline.diffEnabled).toBe(false)
286284
})
287285

288286
it("should use default fuzzy match threshold when not provided", async () => {
289287
const cline = new Task({
290288
provider: mockProvider,
291289
apiConfiguration: mockApiConfig,
292-
customInstructions: "custom instructions",
293290
enableDiff: true,
294291
fuzzyMatchThreshold: 0.95,
295292
task: "test task",

src/core/webview/ClineProvider.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { supportPrompt } from "../../shared/support-prompt"
1818
import { GlobalFileNames } from "../../shared/globalFileNames"
1919
import { HistoryItem } from "../../shared/HistoryItem"
2020
import { ExtensionMessage } from "../../shared/ExtensionMessage"
21-
import { Mode, PromptComponent, defaultModeSlug } from "../../shared/modes"
21+
import { Mode, defaultModeSlug } from "../../shared/modes"
2222
import { experimentDefault } from "../../shared/experiments"
2323
import { formatLanguage } from "../../shared/language"
2424
import { Terminal } from "../../integrations/terminal/Terminal"
@@ -449,33 +449,21 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
449449
options: Partial<
450450
Pick<
451451
TaskOptions,
452-
| "customInstructions"
453-
| "enableDiff"
454-
| "enableCheckpoints"
455-
| "fuzzyMatchThreshold"
456-
| "consecutiveMistakeLimit"
457-
| "experiments"
452+
"enableDiff" | "enableCheckpoints" | "fuzzyMatchThreshold" | "consecutiveMistakeLimit" | "experiments"
458453
>
459454
> = {},
460455
) {
461456
const {
462457
apiConfiguration,
463-
customModePrompts,
464458
diffEnabled: enableDiff,
465459
enableCheckpoints,
466460
fuzzyMatchThreshold,
467-
mode,
468-
customInstructions: globalInstructions,
469461
experiments,
470462
} = await this.getState()
471463

472-
const modePrompt = customModePrompts?.[mode] as PromptComponent
473-
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")
474-
475464
const cline = new Task({
476465
provider: this,
477466
apiConfiguration,
478-
customInstructions: effectiveInstructions,
479467
enableDiff,
480468
enableCheckpoints,
481469
fuzzyMatchThreshold,
@@ -503,22 +491,15 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
503491

504492
const {
505493
apiConfiguration,
506-
customModePrompts,
507494
diffEnabled: enableDiff,
508495
enableCheckpoints,
509496
fuzzyMatchThreshold,
510-
mode,
511-
customInstructions: globalInstructions,
512497
experiments,
513498
} = await this.getState()
514499

515-
const modePrompt = customModePrompts?.[mode] as PromptComponent
516-
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")
517-
518500
const cline = new Task({
519501
provider: this,
520502
apiConfiguration,
521-
customInstructions: effectiveInstructions,
522503
enableDiff,
523504
enableCheckpoints,
524505
fuzzyMatchThreshold,
@@ -962,11 +943,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
962943
async updateCustomInstructions(instructions?: string) {
963944
// User may be clearing the field.
964945
await this.updateGlobalState("customInstructions", instructions || undefined)
965-
966-
if (this.getCurrentCline()) {
967-
this.getCurrentCline()!.customInstructions = instructions || undefined
968-
}
969-
970946
await this.postStateToWebview()
971947
}
972948

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -806,45 +806,6 @@ describe("ClineProvider", () => {
806806
expect(mockPostMessage).toHaveBeenCalled()
807807
})
808808

809-
test("uses mode-specific custom instructions in Cline initialization", async () => {
810-
// Setup mock state
811-
const modeCustomInstructions = "Code mode instructions"
812-
const mockApiConfig = {
813-
apiProvider: "openrouter",
814-
}
815-
816-
jest.spyOn(provider, "getState").mockResolvedValue({
817-
apiConfiguration: mockApiConfig,
818-
customModePrompts: {
819-
code: { customInstructions: modeCustomInstructions },
820-
},
821-
mode: "code",
822-
diffEnabled: true,
823-
enableCheckpoints: false,
824-
fuzzyMatchThreshold: 1.0,
825-
experiments: experimentDefault,
826-
} as any)
827-
828-
// Initialize Cline with a task
829-
await provider.initClineWithTask("Test task")
830-
831-
// Verify Cline was initialized with mode-specific instructions
832-
expect(Task).toHaveBeenCalledWith({
833-
provider,
834-
apiConfiguration: mockApiConfig,
835-
customInstructions: modeCustomInstructions,
836-
enableDiff: true,
837-
enableCheckpoints: false,
838-
fuzzyMatchThreshold: 1.0,
839-
task: "Test task",
840-
experiments: experimentDefault,
841-
rootTask: undefined,
842-
parentTask: undefined,
843-
taskNumber: 1,
844-
onCreated: expect.any(Function),
845-
})
846-
})
847-
848809
test("handles mode-specific custom instructions updates", async () => {
849810
await provider.resolveWebviewView(mockWebviewView)
850811
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]

0 commit comments

Comments
 (0)