Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions packages/types/src/__tests__/experiment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { experimentIds, experimentIdsSchema, experimentsSchema } from "../experiment.js"

describe("dynamicThinkingEffort experiment", () => {
it("is part of the experiment id enum", () => {
expect(experimentIds).toContain("dynamicThinkingEffort")
expect(experimentIdsSchema.safeParse("dynamicThinkingEffort").success).toBe(true)
})

it("parses enabled and disabled states", () => {
expect(experimentsSchema.parse({ dynamicThinkingEffort: true })).toEqual({ dynamicThinkingEffort: true })
expect(experimentsSchema.parse({ dynamicThinkingEffort: false })).toEqual({ dynamicThinkingEffort: false })
expect(experimentsSchema.parse({})).toEqual({})
})

it("rejects non-boolean values", () => {
expect(experimentsSchema.safeParse({ dynamicThinkingEffort: "yes" }).success).toBe(false)
expect(experimentIdsSchema.safeParse("dynamic-thinking-effort").success).toBe(false)
})
})
2 changes: 2 additions & 0 deletions packages/types/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const experimentIds = [
"runSlashCommand",
"customTools",
"parallelToolExecution",
"dynamicThinkingEffort",
] as const

export const experimentIdsSchema = z.enum(experimentIds)
Expand All @@ -28,6 +29,7 @@ export const experimentsSchema = z.object({
runSlashCommand: z.boolean().optional(),
customTools: z.boolean().optional(),
parallelToolExecution: z.boolean().optional(),
dynamicThinkingEffort: z.boolean().optional(),
})

export type Experiments = z.infer<typeof experimentsSchema>
Expand Down
25 changes: 24 additions & 1 deletion src/shared/__tests__/experiments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import type { ExperimentId } from "@roo-code/types"

import { EXPERIMENT_IDS, experimentConfigsMap, experiments as Experiments } from "../experiments"
import { EXPERIMENT_IDS, experimentConfigsMap, experimentDefault, experiments as Experiments } from "../experiments"

describe("experiments", () => {
describe("PREVENT_FOCUS_DISRUPTION", () => {
Expand All @@ -22,6 +22,7 @@ describe("experiments", () => {
runSlashCommand: false,
customTools: false,
parallelToolExecution: false,
dynamicThinkingEffort: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(false)
})
Expand All @@ -33,6 +34,7 @@ describe("experiments", () => {
runSlashCommand: false,
customTools: false,
parallelToolExecution: false,
dynamicThinkingEffort: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(true)
})
Expand All @@ -44,6 +46,7 @@ describe("experiments", () => {
runSlashCommand: false,
customTools: false,
parallelToolExecution: false,
dynamicThinkingEffort: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(false)
})
Expand All @@ -66,4 +69,24 @@ describe("experiments", () => {
expect(Experiments.isEnabled({ parallelToolExecution: true }, "parallelToolExecution")).toBe(true)
})
})

describe("DYNAMIC_THINKING_EFFORT", () => {
it("is configured correctly", () => {
expect(EXPERIMENT_IDS.DYNAMIC_THINKING_EFFORT).toBe("dynamicThinkingEffort")
expect(experimentConfigsMap.DYNAMIC_THINKING_EFFORT).toMatchObject({
enabled: false,
})
// Visible in the Settings panel (showInSettings defaults to true).
expect(experimentConfigsMap.DYNAMIC_THINKING_EFFORT.showInSettings).toBeUndefined()
})

it("is disabled by default", () => {
expect(experimentDefault.dynamicThinkingEffort).toBe(false)
expect(Experiments.isEnabled({}, "dynamicThinkingEffort")).toBe(false)
})

it("returns true when enabled", () => {
expect(Experiments.isEnabled({ dynamicThinkingEffort: true }, "dynamicThinkingEffort")).toBe(true)
})
})
})
2 changes: 2 additions & 0 deletions src/shared/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const EXPERIMENT_IDS = {
RUN_SLASH_COMMAND: "runSlashCommand",
CUSTOM_TOOLS: "customTools",
PARALLEL_TOOL_EXECUTION: "parallelToolExecution",
DYNAMIC_THINKING_EFFORT: "dynamicThinkingEffort",
} as const satisfies Record<string, ExperimentId>

type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
Expand All @@ -25,6 +26,7 @@ export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
CUSTOM_TOOLS: { enabled: false },
// TODO: add i18n keys (settings:experimental.PARALLEL_TOOL_EXECUTION.name/.description) in the same PR that sets showInSettings: true
PARALLEL_TOOL_EXECUTION: { enabled: false, showInSettings: false },
DYNAMIC_THINKING_EFFORT: { enabled: false },
}

export const experimentDefault = Object.fromEntries(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react"
import { fireEvent, render, screen } from "@testing-library/react"

import { experimentDefault } from "@roo/experiments"

Expand Down Expand Up @@ -32,4 +32,31 @@ describe("ExperimentalSettings", () => {
expect(screen.getByText("settings:experimental.CUSTOM_TOOLS.name")).toBeInTheDocument()
expect(screen.queryByText("settings:experimental.PARALLEL_TOOL_EXECUTION.name")).not.toBeInTheDocument()
})

it("renders the dynamic thinking effort toggle", () => {
render(<ExperimentalSettings {...defaultProps} />)

expect(screen.getByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name")).toBeInTheDocument()
})

it("binds the dynamic thinking effort toggle to setExperimentEnabled", () => {
const setExperimentEnabled = vi.fn()
render(
<ExperimentalSettings
{...defaultProps}
experiments={{ ...experimentDefault, dynamicThinkingEffort: true }}
setExperimentEnabled={setExperimentEnabled}
/>,
)

const label = screen.getByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name").closest("label")
const checkbox = label?.querySelector("input[type='checkbox']")
expect(checkbox).not.toBeNull()
expect(checkbox).toBeChecked()

fireEvent.click(checkbox!)

expect(setExperimentEnabled).toHaveBeenCalledTimes(1)
expect(setExperimentEnabled).toHaveBeenCalledWith("dynamicThinkingEffort", false)
})
})
4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ca/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/de/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,10 @@
"refreshSuccess": "Tools refreshed successfully",
"refreshError": "Failed to refresh tools",
"toolParameters": "Parameters"
},
"DYNAMIC_THINKING_EFFORT": {
"name": "Dynamic thinking effort",
"description": "Let the model decide its thinking effort per step, and let you adjust it in-chat. (experimental)"
}
},
"promptCaching": {
Expand Down
4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/es/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/fr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/hi/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/id/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/it/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ja/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ko/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/nl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/pl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/pt-BR/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ru/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/tr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/vi/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/zh-CN/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/zh-TW/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading