Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/core/environment/__tests__/getEnvironmentDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,21 @@ describe("getEnvironmentDetails", () => {
expect(mockInactiveTerminal.getCurrentWorkingDirectory).toHaveBeenCalled()
})

it("should include experiment-specific details when Power Steering is enabled", async () => {
it("should always include mode role and custom instructions regardless of Power Steering", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test coverage for both scenarios! The test name clearly indicates the behavior we're verifying - that mode instructions should always be included regardless of experimental features.

// Test with Power Steering disabled
mockState.experiments = { [EXPERIMENT_IDS.POWER_STEERING]: false }
;(experiments.isEnabled as Mock).mockReturnValue(false)

let result = await getEnvironmentDetails(mockCline as Task)

expect(result).toContain("<role>You are a code assistant</role>")
expect(result).toContain("<custom_instructions>Custom instructions</custom_instructions>")

// Test with Power Steering enabled
mockState.experiments = { [EXPERIMENT_IDS.POWER_STEERING]: true }
;(experiments.isEnabled as Mock).mockReturnValue(true)

const result = await getEnvironmentDetails(mockCline as Task)
result = await getEnvironmentDetails(mockCline as Task)

expect(result).toContain("<role>You are a code assistant</role>")
expect(result).toContain("<custom_instructions>Custom instructions</custom_instructions>")
Expand Down
9 changes: 3 additions & 6 deletions src/core/environment/getEnvironmentDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,10 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
details += `<slug>${currentMode}</slug>\n`
details += `<name>${modeDetails.name}</name>\n`
details += `<model>${modelId}</model>\n`
details += `<role>${modeDetails.roleDefinition}</role>\n`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix! This correctly ensures mode instructions are always included. Though after this change, you might want to check if the EXPERIMENT_IDS import is still needed in this file since we're no longer checking for POWER_STEERING.


if (Experiments.isEnabled(experiments ?? {}, EXPERIMENT_IDS.POWER_STEERING)) {
details += `<role>${modeDetails.roleDefinition}</role>\n`

if (modeDetails.customInstructions) {
details += `<custom_instructions>${modeDetails.customInstructions}</custom_instructions>\n`
}
if (modeDetails.customInstructions) {
details += `<custom_instructions>${modeDetails.customInstructions}</custom_instructions>\n`
}

if (includeFileDetails) {
Expand Down
Loading