Skip to content

🙌 OpenHands: AI-Driven Development

feat(settings): expose the LLM-switching toggle in Agent settings (#16441)

george larson46e44c10d3eb
diff --git a/__tests__/api/agent-profiles-service/profile-field-support.test.ts b/__tests__/api/agent-profiles-service/profile-field-support.test.ts
new file mode 100644
index 0000000000..d2635197ab
--- /dev/null
+++ b/__tests__/api/agent-profiles-service/profile-field-support.test.ts
@@ -0,0 +1,59 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ MIN_AGENT_SERVER_VERSION_FOR_PROFILE_SWITCH_LLM_TOOL,
+ agentProfileSupportsSwitchLlmTool,
+} from "#/api/agent-profiles-service/profile-field-support";
+
+const mockGetCachedAgentServerVersion = vi.fn<() => string | null>();
+
+// Only the version *lookup* is mocked — the comparison stays the real one so
+// these cases exercise the same parser the boot-time compatibility check uses.
+vi.mock("#/api/agent-server-compatibility", async (importOriginal) => {
+ const actual =
+ await importOriginal<typeof import("#/api/agent-server-compatibility")>();
+ return {
+ ...actual,
+ getCachedAgentServerVersion: () => mockGetCachedAgentServerVersion(),
+ };
+});
+
+describe("agentProfileSupportsSwitchLlmTool", () => {
+ beforeEach(() => {
+ mockGetCachedAgentServerVersion.mockReset();
+ });
+
+ it("pins the gate to the release that added the profile field", () => {
+ expect(MIN_AGENT_SERVER_VERSION_FOR_PROFILE_SWITCH_LLM_TOOL).toBe("1.31.0");
+ });
+
+ it.each(["1.29.0", "1.29.3", "1.30.0"])(
+ "reports no support on %s, where agent profiles exist but the field does not",
+ (version) => {
+ mockGetCachedAgentServerVersion.mockReturnValue(version);
+ expect(agentProfileSupportsSwitchLlmTool()).toBe(false);
+ },
+ );
+
+ it.each(["1.31.0", "1.31.2", "1.36.1", "2.0.0"])(
+ "reports support on %s",
+ (version) => {
+ mockGetCachedAgentServerVersion.mockReturnValue(version);
+ expect(agentProfileSupportsSwitchLlmTool()).toBe(true);
+ },
+ );
+
+ it("treats a prerelease of the gating version as older", () => {
+ mockGetCachedAgentServerVersion.mockReturnValue("1.31.0-rc.1");
+ expect(agentProfileSupportsSwitchLlmTool()).toBe(false);
+ });
+
+ it("assumes support when no version is cached (cloud backends)", () => {
+ mockGetCachedAgentServerVersion.mockReturnValue(null);
+ expect(agentProfileSupportsSwitchLlmTool()).toBe(true);
+ });
+
+ it("assumes support when the reported version does not parse", () => {
+ mockGetCachedAgentServerVersion.mockReturnValue("main");
+ expect(agentProfileSupportsSwitchLlmTool()).toBe(true);
+ });
+});
diff --git a/__tests__/components/home/llm-not-configured-banner.test.tsx b/__tests__/components/home/llm-not-configured-banner.test.tsx
index 90229f8548..13177d16b0 100644
--- a/__tests__/components/home/llm-not-configured-banner.test.tsx
+++ b/__tests__/components/home/llm-not-configured-banner.test.tsx
@@ -11,6 +11,7 @@ import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";
import SettingsService from "#/api/settings-service/settings-service.api";
import OptionService from "#/api/option-service/option-service.api";
import ProfilesService from "#/api/profiles-service/profiles-service.api";
+import AgentProfilesService from "#/api/agent-profiles-service/agent-profiles-service.api";
import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";
import { Settings } from "#/types/settings";
import { WebClientConfig } from "#/api/option-service/option.types";
@@ -150,6 +151,25 @@ describe("LlmNotConfiguredBanner", () => {
it("stays hidden for ACP agents, which own their LLM and need no key", async () => {
// Arrange: ACP agent, no key — must not be nagged.
+ //
+ // The ACTIVE AGENT PROFILE is what decides this; `agent_settings` is only
+ // the fallback while the profile list loads. Both are set to ACP here so
+ // the case states its own intent — before the mock handlers covered
+ // /api/agent-profiles, this passed because the list request errored and
+ // left the hook on the settings fallback.
+ vi.spyOn(AgentProfilesService, "listProfiles").mockResolvedValue({
+ profiles: [
+ {
+ id: "acp-profile-id",
+ name: "acp",
+ agent_kind: "acp",
+ revision: 1,
+ llm_profile_ref: null,
+ mcp_server_refs: null,
+ },
+ ],
+ active_agent_profile_id: "acp-profile-id",
+ });
vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
buildSettings({
llm_api_key_set: false,
diff --git a/__tests__/components/settings/agent-profiles/agent-profiles-local-view.test.tsx b/__tests__/components/settings/agent-profiles/agent-profiles-local-view.test.tsx
index 9654d37706..c3884a3dbc 100644
--- a/__tests__/components/settings/agent-profiles/agent-profiles-local-view.test.tsx
+++ b/__tests__/components/settings/agent-profiles/agent-profiles-local-view.test.tsx
@@ -20,14 +20,23 @@ vi.mock("react-i18next", () => ({
// the named export to match; the factory is hoisted, so define the stub inline.
vi.mock("#/routes/agent-settings", () => {
const MockAgentSettings = ({
+ agentSettingsOverride,
onSaveControlChange,
}: {
+ agentSettingsOverride?: Record<string, unknown> | null;
onSaveControlChange?: (c: AgentSettingsSaveControl) => void;
}) => {
useEffect(() => {
if (emitControl) onSaveControlChange?.(emitControl);
}, [onSaveControlChange]);
- return <div data-testid="mock-agent-settings" />;
+ // Surface the seed override so tests can assert what the embedded form
+ // would open on.
+ return (
+ <div
+ data-testid="mock-agent-settings"
+ data-override={JSON.stringify(agentSettingsOverride)}
+ />
+ );
};
return {
__esModule: true,
@@ -214,6 +223,22 @@ describe("AgentProfilesLocalView save mapping", () => {
const user = userEvent.setup();
await user.click(screen.getByTestId("edit-agent-profile"));
await screen.findByTestId("mock-agent-settings");
+
+ // The embedded form is seeded from the stored profile — including
+ // `enable_switch_llm_tool`, which the editor now models. (Asserted before
+ // the save: a successful save returns to the list and unmounts the form.)
+ const seededOverride = JSON.parse(
+ screen
+ .getByTestId("mock-agent-settings")
+ .getAttribute("data-override") as string,
+ );
+ expect(seededOverride).toMatchObject({
+ agent_kind: "openhands",
+ enable_sub_agents: false,
+ enable_switch_llm_tool: false,
+ tool_concurrency_limit: 4,
+ });
+
await user.click(screen.getByTestId("save-agent-profile-btn"));
await waitFor(() => expect(saveMutate).toHaveBeenCalledTimes(1));
@@ -241,6 +266,45 @@ describe("AgentProfilesLocalView save mapping", () => {
expect(profile).not.toHaveProperty("revision");
});
+ it("edit-save persists an edited enable_switch_llm_tool over the stored value", async () => {
+ // The stored profile has the tool disabled; the embedded form's builder
+ // emits the edited value, which must win over the stored one in the
+ // whole-profile overwrite.
+ vi.mocked(AgentProfilesService.getProfile).mockResolvedValue({
+ name: "default",
+ profile: {
+ schema_version: 1,
+ id: "p-1",
+ name: "default",
+ revision: 3,
+ agent_kind: "openhands",
+ llm_profile_ref: "default",
+ enable_sub_agents: false,
+ enable_switch_llm_tool: false,
+ },
+ } as never);
+ emitControl = {
+ agentType: "openhands",
+ isValid: true,
+ buildAgentProfileFields: () => ({
+ agent_kind: "openhands",
+ enable_sub_agents: false,
+ enable_switch_llm_tool: true,
+ }),
+ credentials: { isDirty: false, save: vi.fn(), reset: vi.fn() },
+ };
+
+ render(<AgentProfilesLocalView />);
+ const user = userEvent.setup();
+ await user.click(screen.getByTestId("edit-agent-profile"));
+ await screen.findByTestId("mock-agent-settings");
+ await user.click(screen.getByTestId("save-agent-profile-btn"));
+
+ await waitFor(() => expect(saveMutate).toHaveBeenCalledTimes(1));
+ const { profile } = saveMutate.mock.calls[0][0];
+ expect(profile.enable_switch_llm_tool).toBe(true);
+ });
+
it("kind-switch edit-save sends a clean variant payload", async () => {
vi.mocked(AgentProfilesService.getProfile).mockResolvedValue({
name: "default",
diff --git a/__tests__/components/settings/agent-profiles/merge-agent-profile-save-input.test.ts b/__tests__/components/settings/agent-profiles/merge-agent-profile-save-input.test.ts
index 418744bce3..0c889b9289 100644
--- a/__tests__/components/settings/agent-profiles/merge-agent-profile-save-input.test.ts
+++ b/__tests__/components/settings/agent-profiles/merge-agent-profile-save-input.test.ts
@@ -79,6 +79,22 @@ describe("mergeAgentProfileSaveInput", () => {
});
});
+ it("lets an edited enable_switch_llm_tool win over the stored value", () => {
+ // The editor now models the field, so an edited value must override the
+ // stored one rather than being carried under it. The field rides untyped
+ // (the pinned ts-client predates it), hence the cast.
+ const edited = {
+ agent_kind: "openhands",
+ enable_sub_agents: false,
+ enable_switch_llm_tool: true,
+ llm_profile_ref: "new-llm",
+ } as unknown as AgentProfileSaveInput;
+
+ const merged = mergeAgentProfileSaveInput(storedOpenHands, edited);
+
+ expect(merged).toMatchObject({ enable_switch_llm_tool: true });
+ });
+
it("preserves unmodeled ACP fields under the edited ones", () => {
const edited: AgentProfileSaveInput = {
agent_kind: "acp",
diff --git a/__tests__/routes/agent-settings.test.tsx b/__tests__/routes/agent-settings.test.tsx
index 8a7a6727fa..4470869a78 100644
--- a/__tests__/routes/agent-settings.test.tsx
+++ b/__tests__/routes/agent-settings.test.tsx
@@ -16,6 +16,14 @@ vi.mock("#/hooks/query/use-acp-auth-status", () => ({
useAcpAuthStatus: (...args: unknown[]) => acpAuthStatusMock(...args),
}));
+// The profile editor gates the LLM-switching toggle on the backend's *profile*
+// model, which gained the field later than the settings schema did. Stub the
+// probe so both sides of that gate are reachable without a live server.
+const profileSupportsSwitchLlmToolMock = vi.hoisted(() => vi.fn(() => true));
+vi.mock("#/api/agent-profiles-service/profile-field-support", () => ({
+ agentProfileSupportsSwitchLlmTool: () => profileSupportsSwitchLlmToolMock(),
+}));
+
// Observe save toasts so we can assert the single Save shows one confirmation,
// not one per persisted thing (agent spec + credentials).
const toastMocks = vi.hoisted(() => ({
@@ -38,8 +46,10 @@ function buildSettings(overrides: Partial<Settings> = {}): Settings {
};
}
-function renderAgentSettingsScreen() {
- return render(<AgentSettingsScreen />, {
+function renderAgentSettingsScreen(
+ props: React.ComponentProps<typeof AgentSettingsScreen> = {},
+) {
+ return render(<AgentSettingsScreen {...props} />, {
wrapper: ({ children }) => (
<MemoryRouter>
<QueryClientProvider
@@ -70,6 +80,7 @@ describe("AgentSettingsScreen", () => {
toastMocks.success.mockClear();
toastMocks.error.mockClear();
toastMocks.warning.mockClear();
+ profileSupportsSwitchLlmToolMock.mockReturnValue(true);
});
it("renders the agent type selector defaulting to OpenHands with sub-agents toggle", async () => {
@@ -149,10 +160,159 @@ describe("AgentSettingsScreen", () => {
expect(call.agent_settings_diff).toEqual({
agent_kind: "openhands",
enable_sub_agents: true,
+ enable_switch_llm_tool: true,
tool_concurrency_limit: 1,
});
});
+ it("renders the LLM-switching toggle on the OpenHands path and saves it when toggled off", async () => {
+ const user = userEvent.setup();
+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
+ buildSettings({
+ agent_settings: {
+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,
+ agent_kind: "openhands",
+ enable_switch_llm_tool: true,
+ },
+ }),
+ );
+ const save = vi.spyOn(SettingsService, "saveSettings");
+
+ renderAgentSettingsScreen();
+ await screen.findByTestId("agent-settings-screen");
+
+ // The toggle renders (schema exposes the field) and starts on.
+ const toggle = screen.getByTestId("agent-settings-enable-switch-llm-tool");
+ expect(toggle).toBeChecked();
+
+ // Toggle it off via the enclosing label, then save.
+ const label = toggle.closest("label")!;
+ await user.click(label);
+ expect(toggle).not.toBeChecked();
+
+ await user.click(screen.getByTestId("agent-save-button"));
+
+ await waitFor(() => {
+ expect(save).toHaveBeenCalledTimes(1);
+ });
+ const call = save.mock.calls[0]?.[0] as {
+ agent_settings_diff?: Record<string, unknown>;
+ };
+ expect(call.agent_settings_diff).toEqual({
+ agent_kind: "openhands",
+ enable_sub_agents: false,
+ enable_switch_llm_tool: false,
+ tool_concurrency_limit: 1,
+ });
+ });
+
+ it("hides the LLM-switching toggle when the schema predates the field", async () => {
+ const schema = MOCK_DEFAULT_USER_SETTINGS.agent_settings_schema;
+ const schemaWithoutField = schema && {
+ ...schema,
+ sections: schema.sections.map((section) => ({
+ ...section,
+ fields: section.fields.filter(
+ (field) => field.key !== "enable_switch_llm_tool",
+ ),
+ })),
+ };
+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
+ buildSettings({
+ agent_settings_schema: schemaWithoutField,
+ agent_settings: {
+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,
+ agent_kind: "openhands",
+ },
+ }),
+ );
+
+ renderAgentSettingsScreen();
+ await screen.findByTestId("agent-settings-screen");
+
+ // Older agent-servers without the field hide the toggle cleanly...
+ expect(
+ screen.queryByTestId("agent-settings-enable-switch-llm-tool"),
+ ).not.toBeInTheDocument();
+ // ...while the other OpenHands controls still render.
+ expect(
+ screen.getByTestId("agent-settings-enable-sub-agents"),
+ ).toBeInTheDocument();
+ });
+
+ it("hides the LLM-switching toggle in the profile editor when the profile model predates the field", async () => {
+ // agent-server 1.29.0–1.30.x advertises the field in the settings schema
+ // while `OpenHandsAgentProfile` still rejects it. Rendering the toggle
+ // there would offer a control whose save the server refuses outright.
+ profileSupportsSwitchLlmToolMock.mockReturnValue(false);
+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
+ buildSettings({
+ agent_settings: {
+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,
+ agent_kind: "openhands",
+ },
+ }),
+ );
+
+ renderAgentSettingsScreen({
+ embedded: true,
+ agentSettingsOverride: { agent_kind: "openhands" },
+ });
+ await screen.findByTestId("agent-settings-screen");
+
+ expect(
+ screen.queryByTestId("agent-settings-enable-switch-llm-tool"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.getByTestId("agent-settings-enable-sub-agents"),
+ ).toBeInTheDocument();
+ });
+
+ it("renders the LLM-switching toggle in the profile editor once the profile model carries the field", async () => {
+ profileSupportsSwitchLlmToolMock.mockReturnValue(true);
+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
+ buildSettings({
+ agent_settings: {
+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,
+ agent_kind: "openhands",
+ },
+ }),
+ );
+
+ renderAgentSettingsScreen({
+ embedded: true,
+ agentSettingsOverride: { agent_kind: "openhands" },
+ });
+ await screen.findByTestId("agent-settings-screen");
+
+ expect(
+ screen.getByTestId("agent-settings-enable-switch-llm-tool"),
+ ).toBeInTheDocument();
+ });
+
+ it("keeps the LLM-switching toggle in non-embedded mode even when the profile model predates the field", async () => {
+ // Non-embedded, the form writes `agent_settings`, which has accepted the
+ // key since 1.22.0. The profile-model gap must not reach back and hide it.
+ // (That mode has no route today — #1571 turned /settings/agent into a
+ // redirect — but the gate should stay scoped to what it actually knows.)
+ profileSupportsSwitchLlmToolMock.mockReturnValue(false);
+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
+ buildSettings({
+ agent_settings: {
+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,
+ agent_kind: "openhands",
+ },
+ }),
+ );
+
+ renderAgentSettingsScreen();
+ await screen.findByTestId("agent-settings-screen");
+
+ expect(
+ screen.getByTestId("agent-settings-enable-switch-llm-tool"),
+ ).toBeInTheDocument();
+ });
+
it("saves tool_concurrency_limit when changed on the OpenHands path", async () => {
const user = userEvent.setup();
vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
@@ -498,6 +658,7 @@ describe("AgentSettingsScreen", () => {
expect(call.agent_settings_diff).toEqual({
agent_kind: "openhands",
enable_sub_agents: false,
+ enable_switch_llm_tool: true,
tool_concurrency_limit: 1,
});
});
diff --git a/__tests__/routes/build-agent-profile-fields.test.ts b/__tests__/routes/build-agent-profile-fields.test.ts
index 3d20ddee4b..fcfba98b6b 100644
--- a/__tests__/routes/build-agent-profile-fields.test.ts
+++ b/__tests__/routes/build-agent-profile-fields.test.ts
@@ -9,10 +9,27 @@ const baseAcp = {
commandTokens: ["npx", "-y", "@zed-industries/claude-code-acp"],
acpModel: "claude-opus-4-8",
subAgentsEnabled: false,
+ switchLlmToolField: undefined,
+ switchLlmToolEnabled: false,
+ switchLlmToolSupportedOnProfile: true,
toolConcurrencyField: undefined,
toolConcurrency: "",
};
+const switchLlmToolField: SettingsFieldSchema = {
+ key: "enable_switch_llm_tool",
+ label: "Enable LLM switching tool",
+ section: "general",
+ section_label: "General",
+ value_type: "boolean",
+ default: true,
+ choices: [],
+ depends_on: [],
+ prominence: "major",
+ secret: false,
+ required: false,
+};
+
const concurrencyField: SettingsFieldSchema = {
key: "tool_concurrency_limit",
label: "Tool concurrency limit",
@@ -82,6 +99,9 @@ describe("buildAgentProfileFields — OpenHands", () => {
commandTokens: [],
acpModel: "",
subAgentsEnabled: true,
+ switchLlmToolField: undefined,
+ switchLlmToolEnabled: false,
+ switchLlmToolSupportedOnProfile: true,
toolConcurrencyField: undefined,
toolConcurrency: "",
};
@@ -93,6 +113,43 @@ describe("buildAgentProfileFields — OpenHands", () => {
});
});
+ it("emits enable_switch_llm_tool when the schema exposes the field", () => {
+ const fields = buildAgentProfileFields({
+ ...baseOh,
+ switchLlmToolField,
+ switchLlmToolEnabled: true,
+ });
+ if (fields.agent_kind === "openhands") {
+ expect(fields.enable_switch_llm_tool).toBe(true);
+ }
+ });
+
+ it("omits enable_switch_llm_tool when the schema has it but the profile model does not", () => {
+ // agent-server 1.29.0–1.30.x: agent profiles exist and the settings schema
+ // advertises the field, but `OpenHandsAgentProfile` gained it in 1.31.0.
+ // The profile POST is `extra="forbid"`, so emitting here 422s the save.
+ const fields = buildAgentProfileFields({
+ ...baseOh,
+ switchLlmToolField,
+ switchLlmToolEnabled: false,
+ switchLlmToolSupportedOnProfile: false,
+ });
+ expect(fields).not.toHaveProperty("enable_switch_llm_tool");
+ });
+
+ it("omits enable_switch_llm_tool when the schema predates the field", () => {
+ // Older agent-servers would reject the unknown key on the whole-profile
+ // overwrite, so the key is only emitted when the schema advertises it.
+ const fields = buildAgentProfileFields({
+ ...baseOh,
+ switchLlmToolField: undefined,
+ switchLlmToolEnabled: true,
+ });
+ if (fields.agent_kind === "openhands") {
+ expect(fields).not.toHaveProperty("enable_switch_llm_tool");
+ }
+ });
+
it("coerces a valid tool_concurrency_limit to a number", () => {
const fields = buildAgentProfileFields({
...baseOh,
diff --git a/src/api/agent-profiles-service/profile-field-support.ts b/src/api/agent-profiles-service/profile-field-support.ts
new file mode 100644
index 0000000000..71e0c0b25e
--- /dev/null
+++ b/src/api/agent-profiles-service/profile-field-support.ts
@@ -0,0 +1,41 @@
+import {
+ compareAgentServerVersions,
+ getCachedAgentServerVersion,
+} from "#/api/agent-server-compatibility";
+
+/**
+ * `enable_switch_llm_tool` reached `OpenHandsAgentProfile` in
+ * software-agent-sdk#3870, first released in agent-server 1.31.0. The same
+ * field reached `AgentSettingsConfig` far earlier (1.22.0), so the agent
+ * settings schema advertises it on servers whose *profile* model still
+ * rejects it.
+ *
+ * That gap sits inside the supported range rather than below it: agent
+ * profiles shipped in 1.29.0 and Canvas accepts back to
+ * `config/defaults.json`'s `compatibility.minimumAgentServer`. On 1.29.0
+ * through 1.30.x, `AgentProfileBase` is `extra="forbid"`, so a profile save
+ * carrying the key 422s and the whole save is lost. Hence the profile editor
+ * gates on the server version instead of reusing the settings schema's
+ * presence check, which answers a different question.
+ */
+export const MIN_AGENT_SERVER_VERSION_FOR_PROFILE_SWITCH_LLM_TOOL = "1.31.0";
+
+/**
+ * Whether the active backend's agent-profile model accepts
+ * `enable_switch_llm_tool`.
+ *
+ * An unreadable version counts as support, matching the other version-gated
+ * call sites: cloud backends expose no `/server_info` to probe and track the
+ * current contract, and a local backend whose version does not parse never
+ * gets past `assertAgentServerVersionIsSupported` at boot.
+ */
+export function agentProfileSupportsSwitchLlmTool(): boolean {
+ const version = getCachedAgentServerVersion();
+ if (!version) return true;
+ const comparison = compareAgentServerVersions(
+ version,
+ MIN_AGENT_SERVER_VERSION_FOR_PROFILE_SWITCH_LLM_TOOL,
+ );
+ if (comparison === null) return true;
+ return comparison >= 0;
+}
diff --git a/src/components/features/settings/agent-profiles/agent-profiles-local-view.tsx b/src/components/features/settings/agent-profiles/agent-profiles-local-view.tsx
index e9162a9a3a..ee30894a88 100644
--- a/src/components/features/settings/agent-profiles/agent-profiles-local-view.tsx
+++ b/src/components/features/settings/agent-profiles/agent-profiles-local-view.tsx
@@ -50,9 +50,17 @@ function toAgentSettingsOverride(
acp_model: profile.acp_model ?? "",
};
}
+ // `enable_switch_llm_tool` rides untyped — the pinned ts-client predates it
+ // on the profile model (same pattern as `disabled_skills` in the merge
+ // fixtures). Fall back to the SDK default (true) when a stored profile
+ // predates the field.
+ const switchLlmToolEnabled =
+ (profile as { enable_switch_llm_tool?: boolean }).enable_switch_llm_tool ??
+ true;
return {
agent_kind: "openhands",
enable_sub_agents: profile.enable_sub_agents,
+ enable_switch_llm_tool: switchLlmToolEnabled,
tool_concurrency_limit: profile.tool_concurrency_limit,
};
}
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 09648deae9..fc05f272ba 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -2430,6 +2430,40 @@
"uk": "Увімкнути субагентів",
"ca": "Activa subagents"
},
+ "SCHEMA$ENABLE_SWITCH_LLM_TOOL$DESCRIPTION": {
+ "en": "Allow the agent to move this conversation to another saved LLM profile on its own. Disable to remove that tool.",
+ "ja": "エージェントがこの会話を別の保存済み LLM プロファイルへ自動的に移すことを許可します。無効にするとそのツールが削除されます。",
+ "zh-CN": "允许智能体自行将当前对话切换到另一个已保存的 LLM 配置。禁用后将移除该工具。",
+ "zh-TW": "允許代理自行將目前對話切換到另一個已儲存的 LLM 設定檔。停用後將移除該工具。",
+ "ko-KR": "에이전트가 이 대화를 다른 저장된 LLM 프로필로 스스로 전환하는 것을 허용합니다. 비활성화하면 해당 도구가 제거됩니다.",
+ "no": "La agenten flytte denne samtalen til en annen lagret LLM-profil på egen hånd. Deaktiver for å fjerne verktøyet.",
+ "it": "Consenti all'agente di spostare autonomamente questa conversazione su un altro profilo LLM salvato. Disattiva per rimuovere lo strumento.",
+ "pt": "Permite que o agente mova esta conversa para outro perfil de LLM salvo por conta própria. Desative para remover essa ferramenta.",
+ "es": "Permite que el agente traslade esta conversación a otro perfil de LLM guardado por su cuenta. Desactívalo para eliminar esa herramienta.",
+ "ar": "السماح للوكيل بنقل هذه المحادثة إلى ملف LLM شخصي آخر محفوظ من تلقاء نفسه. عطّل هذا الخيار لإزالة تلك الأداة.",
+ "fr": "Permettre à l'agent de transférer lui-même cette conversation vers un autre profil LLM enregistré. Désactivez pour retirer cet outil.",
+ "tr": "Aracının bu konuşmayı kendi kendine kayıtlı başka bir LLM profiline taşımasına izin ver. Bu aracı kaldırmak için devre dışı bırak.",
+ "de": "Erlauben Sie dem Agenten, diese Unterhaltung selbstständig auf ein anderes gespeichertes LLM-Profil zu übertragen. Deaktivieren, um das Werkzeug zu entfernen.",
+ "uk": "Дозволити агенту самостійно переносити цю розмову до іншого збереженого профілю LLM. Вимкніть, щоб прибрати цей інструмент.",
+ "ca": "Permet que l'agent mogui aquesta conversa a un altre perfil d'LLM desat per si mateix. Desactiva-ho per eliminar aquesta eina."
+ },
+ "SCHEMA$ENABLE_SWITCH_LLM_TOOL$LABEL": {
+ "en": "Let the agent switch LLM profiles",
+ "ja": "エージェントによる LLM プロファイルの切り替えを許可する",
+ "zh-CN": "允许智能体切换 LLM 配置",
+ "zh-TW": "允許代理切換 LLM 設定檔",
+ "ko-KR": "에이전트가 LLM 프로필을 전환하도록 허용",
+ "no": "La agenten bytte LLM-profil",
+ "it": "Consenti all'agente di cambiare profilo LLM",
+ "pt": "Permitir que o agente alterne perfis de LLM",
+ "es": "Permitir que el agente cambie de perfil de LLM",
+ "ar": "السماح للوكيل بتبديل ملفات LLM الشخصية",
+ "fr": "Permettre à l'agent de changer de profil LLM",
+ "tr": "Aracının LLM profilleri arasında geçiş yapmasına izin ver",
+ "de": "Agenten das Wechseln von LLM-Profilen erlauben",
+ "uk": "Дозволити агенту перемикати профілі LLM",
+ "ca": "Permet que l'agent canvii de perfil d'LLM"
+ },
"SCHEMA$AGENT_CONTEXT$SECTION_LABEL": {
"en": "Agent Context",
"ja": "エージェントコンテキスト",
diff --git a/src/mocks/agent-profiles-handlers.ts b/src/mocks/agent-profiles-handlers.ts
index d98c9420ac..4fc76fbd6d 100644
--- a/src/mocks/agent-profiles-handlers.ts
+++ b/src/mocks/agent-profiles-handlers.ts
@@ -1,6 +1,7 @@
import { http, HttpResponse } from "msw";
import type {
AgentProfile,
+ AgentProfileSaveInput,
AgentProfileSummary,
} from "@openhands/typescript-client";
@@ -8,6 +9,20 @@ import type {
* In-memory agent-profile store for the mock agent-server API. Keyed by name
* (agent-server uses name-based lookups, not IDs).
*
+ * Two consumers depend on it:
+ *
+ * - Settings → Agent *is* the agent-profile library (#1571), and the embedded
+ * editor behind it is the only surface that renders `AgentSettingsScreen`.
+ * Without a seeded store the page shows "Failed to load profiles" under
+ * `npm run dev:mock`, so the whole agent-settings form is unreachable there.
+ * - `useCreateConversation` no longer downgrades silently when the profile
+ * list fails (#16523): in non-mocked tests `listProfiles` would hit the real
+ * network, reject, and surface as a hard failure.
+ *
+ * State is per-module-load and deliberately in-memory: create, edit, rename
+ * and delete all round-trip so the editor's save path (a whole-profile
+ * overwrite) can be exercised, but nothing persists across a refresh.
+ *
* Imported as a live module so consumers can seed entries and reset between
* tests without re-registering handlers.
*/
@@ -15,12 +30,83 @@ const profiles = new Map<string, AgentProfile>();
let activeProfileId: string | null = null;
-/** Reset the in-memory store (called from test setup, never on main threads). */
+const DEFAULT_VERIFICATION = {
+ critic_enabled: false,
+ critic_mode: "off",
+ enable_iterative_refinement: false,
+ critic_threshold: 0.5,
+ max_refinement_iterations: 3,
+ critic_server_url: null,
+ critic_model_name: null,
+};
+
+function makeOpenHandsProfile(
+ overrides: Partial<AgentProfile> & { id: string; name: string },
+): AgentProfile {
+ return {
+ schema_version: 1,
+ revision: 1,
+ mcp_server_refs: null,
+ agent_kind: "openhands",
+ llm_profile_ref: "default",
+ agent: "CodeActAgent",
+ skills: [],
+ system_message_suffix: null,
+ condenser: null,
+ verification: DEFAULT_VERIFICATION,
+ enable_sub_agents: false,
+ tool_concurrency_limit: 1,
+ ...overrides,
+ } as AgentProfile;
+}
+
+/** Stable id of the seeded `default` profile (the active one after a seed). */
+export const MOCK_DEFAULT_AGENT_PROFILE_ID =
+ "3f1c1b7e-0000-4000-8000-000000000001";
+
+const SEEDED_PROFILES: readonly AgentProfile[] = [
+ makeOpenHandsProfile({
+ id: MOCK_DEFAULT_AGENT_PROFILE_ID,
+ name: "default",
+ }),
+ makeOpenHandsProfile({
+ id: "3f1c1b7e-0000-4000-8000-000000000002",
+ name: "research",
+ enable_sub_agents: true,
+ tool_concurrency_limit: 4,
+ }),
+];
+
+// Monotonic so ids minted after a delete never collide with a live profile.
+let nextProfileSeq = SEEDED_PROFILES.length + 1;
+
+function newProfileId(): string {
+ const suffix = String(nextProfileSeq).padStart(12, "0");
+ nextProfileSeq += 1;
+ return `3f1c1b7e-0000-4000-8000-${suffix}`;
+}
+
+/** Reset the in-memory store to empty (no profiles, no active pointer). */
export function resetMockAgentProfiles(): void {
profiles.clear();
activeProfileId = null;
+ nextProfileSeq = SEEDED_PROFILES.length + 1;
}
+/**
+ * Restore the seeded store: a `default` profile (active, mirroring what the
+ * agent-server seeds on first run) plus a `research` profile so the library
+ * has something to switch between.
+ */
+export function seedMockAgentProfiles(): void {
+ resetMockAgentProfiles();
+ for (const profile of SEEDED_PROFILES) {
+ profiles.set(profile.name, { ...profile });
+ }
+ activeProfileId = MOCK_DEFAULT_AGENT_PROFILE_ID;
+}
+seedMockAgentProfiles();
+
function toSummary(name: string, profile: AgentProfile): AgentProfileSummary {
return {
id: profile.id,
@@ -33,23 +119,24 @@ function toSummary(name: string, profile: AgentProfile): AgentProfileSummary {
};
}
+function notFound(name: string) {
+ return HttpResponse.json(
+ { detail: `Agent profile '${name}' not found` },
+ { status: 404 },
+ );
+}
+
/**
* Mock handlers for the agent-server `/api/agent-profiles` endpoints (the same
- * contract consumed by `AgentProfilesService` and the cloud proxy). Without
- * these, `listProfiles`/`saveProfile` in non-mocked tests hit the real network
- * and reject, which `useCreateConversation` now surfaces as a hard failure
- * (no silent downgrade fallback — see PR #16523).
+ * contract consumed by `AgentProfilesService` and the cloud proxy).
*
- * Routes mirror `agent_profiles_router.py` in the agent-server.
+ * Routes mirror `agent_profiles_router.py` in the agent-server. MSW anchors its
+ * path matcher, so the list route never claims the `:name` routes below and no
+ * extra path guarding is needed.
*/
export const AGENT_PROFILES_HANDLERS = [
// GET /api/agent-profiles - List all profiles + the active id.
- http.get("*/api/agent-profiles", async ({ request }) => {
- // Exclude requests carrying a :name segment (handled by the :name route).
- const url = new URL(request.url);
- const pathParts = url.pathname.split("/").filter(Boolean);
- if (pathParts.length > 2) return undefined;
-
+ http.get("*/api/agent-profiles", async () => {
const summaries = Array.from(profiles.entries()).map(([name, profile]) =>
toSummary(name, profile),
);
@@ -66,39 +153,10 @@ export const AGENT_PROFILES_HANDLERS = [
return HttpResponse.json({ detail: "Invalid name" }, { status: 400 });
}
const profile = profiles.get(name);
- if (!profile) {
- return HttpResponse.json(
- { detail: `Agent profile '${name}' not found` },
- { status: 404 },
- );
- }
+ if (!profile) return notFound(name);
return HttpResponse.json({ name, profile });
}),
- // POST /api/agent-profiles/:name - Create or overwrite a profile (upsert).
- http.post("*/api/agent-profiles/:name", async ({ params, request }) => {
- const { name } = params;
- if (typeof name !== "string") {
- return HttpResponse.json({ detail: "Invalid name" }, { status: 400 });
- }
- const body = (await request.json()) as AgentProfile;
- profiles.set(name, { ...body, id: body.id ?? name });
- return HttpResponse.json({ name, message: "Agent profile saved." });
- }),
-
- // DELETE /api/agent-profiles/:name - Delete by name (idempotent).
- http.delete("*/api/agent-profiles/:name", async ({ params }) => {
- const { name } = params;
- if (typeof name !== "string") {
- return HttpResponse.json({ detail: "Invalid name" }, { status: 400 });
- }
- if (activeProfileId === profiles.get(name)?.id) {
- activeProfileId = null;
- }
- profiles.delete(name);
- return HttpResponse.json({ name, message: "Agent profile deleted." });
- }),
-
// POST /api/agent-profiles/:name/rename - Rename a profile.
http.post(
"*/api/agent-profiles/:name/rename",
@@ -116,14 +174,16 @@ export const AGENT_PROFILES_HANDLERS = [
);
}
const profile = profiles.get(name);
- if (!profile) {
+ if (!profile) return notFound(name);
+ if (newName !== name && profiles.has(newName)) {
return HttpResponse.json(
- { detail: `Agent profile '${name}' not found` },
- { status: 404 },
+ { detail: `Agent profile '${newName}' already exists` },
+ { status: 409 },
);
}
profiles.delete(name);
- profiles.set(newName, profile);
+ // Rename preserves the stable id, and the active pointer with it.
+ profiles.set(newName, { ...profile, name: newName });
return HttpResponse.json({
name: newName,
message: "Agent profile renamed.",
@@ -138,12 +198,7 @@ export const AGENT_PROFILES_HANDLERS = [
return HttpResponse.json({ detail: "Invalid id" }, { status: 400 });
}
const profile = Array.from(profiles.values()).find((p) => p.id === id);
- if (!profile) {
- return HttpResponse.json(
- { detail: `Agent profile '${id}' not found` },
- { status: 404 },
- );
- }
+ if (!profile) return notFound(id);
activeProfileId = id;
return HttpResponse.json({
id,
@@ -151,4 +206,40 @@ export const AGENT_PROFILES_HANDLERS = [
agent_settings_applied: false,
});
}),
+
+ // POST /api/agent-profiles/:name - Create or overwrite a profile (upsert).
+ http.post("*/api/agent-profiles/:name", async ({ params, request }) => {
+ const { name } = params;
+ if (typeof name !== "string") {
+ return HttpResponse.json({ detail: "Invalid name" }, { status: 400 });
+ }
+ const body = (await request.json()) as AgentProfileSaveInput;
+ const existing = profiles.get(name);
+ // Upsert with server-managed identity: the id survives an overwrite and
+ // the revision counter moves, matching `save_profile_preserving_identity`.
+ // A caller-supplied id is honoured only on create, so tests can seed a
+ // profile with a known id and activate it.
+ profiles.set(name, {
+ ...(body as AgentProfile),
+ name,
+ id: existing?.id ?? body.id ?? newProfileId(),
+ revision: (existing?.revision ?? 0) + 1,
+ });
+ return HttpResponse.json({ name, message: "Agent profile saved." });
+ }),
+
+ // DELETE /api/agent-profiles/:name - Delete by name (idempotent).
+ http.delete("*/api/agent-profiles/:name", async ({ params }) => {
+ const { name } = params;
+ if (typeof name !== "string") {
+ return HttpResponse.json({ detail: "Invalid name" }, { status: 400 });
+ }
+ // Deleting the active profile clears the pointer rather than leaving it
+ // dangling; a missing name still resolves 200, as on the server.
+ if (activeProfileId === profiles.get(name)?.id) {
+ activeProfileId = null;
+ }
+ profiles.delete(name);
+ return HttpResponse.json({ name, message: "Agent profile deleted." });
+ }),
];
diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts
index 1267556dd8..5fecad1926 100644
--- a/src/mocks/handlers.ts
+++ b/src/mocks/handlers.ts
@@ -3,6 +3,7 @@ import { SECRETS_HANDLERS } from "./secrets-handlers";
import {
AGENT_PROFILES_HANDLERS,
resetMockAgentProfiles,
+ seedMockAgentProfiles,
} from "./agent-profiles-handlers";
import { GIT_REPOSITORY_HANDLERS } from "./git-repository-handlers";
import {
@@ -46,4 +47,8 @@ export {
resetMockWorkspaces,
};
-export { AGENT_PROFILES_HANDLERS, resetMockAgentProfiles };
+export {
+ AGENT_PROFILES_HANDLERS,
+ resetMockAgentProfiles,
+ seedMockAgentProfiles,
+};
diff --git a/src/mocks/settings-handlers.ts b/src/mocks/settings-handlers.ts
index 9f5db4ca04..7b87e2189b 100644
--- a/src/mocks/settings-handlers.ts
+++ b/src/mocks/settings-handlers.ts
@@ -88,6 +88,21 @@ const MOCK_AGENT_SETTINGS_SCHEMA: NonNullable<
secret: false,
required: false,
},
+ {
+ key: "enable_switch_llm_tool",
+ label: "Enable LLM switching tool",
+ description:
+ "Allow the agent to move the conversation to another saved LLM profile on its own.",
+ section: "general",
+ section_label: "General",
+ value_type: "boolean",
+ default: true,
+ choices: [],
+ depends_on: [],
+ prominence: "major",
+ secret: false,
+ required: false,
+ },
{
key: "tool_concurrency_limit",
label: "Parallel tool calls",
@@ -645,7 +660,12 @@ const MOCK_VERIFIED_MODELS_BY_PROVIDER = MOCK_MODELS.reduce<
return acc;
}, {});
-const MOCK_AGENT_SERVER_VERSION = "1.29.3";
+// Matches the pinned `@openhands/typescript-client`, so mock mode models a
+// server that actually ships this schema. At 1.29.3 the mocked settings schema
+// advertised fields (`enable_switch_llm_tool`) that the mocked server's own
+// profile model would have rejected, and version-gated UI hid controls the
+// rest of the mocks were serving.
+const MOCK_AGENT_SERVER_VERSION = "1.36.1";
// --- Handlers for options/config/settings ---
// Uses wildcard "*" prefix to match both relative paths and absolute URLs
diff --git a/src/routes/agent-settings.tsx b/src/routes/agent-settings.tsx
index 7453742374..33b56ab17a 100644
--- a/src/routes/agent-settings.tsx
+++ b/src/routes/agent-settings.tsx
@@ -39,12 +39,14 @@ import {
type ACPProviderConfig,
} from "#/constants/acp-providers";
import { parseCommand, formatCommand } from "#/utils/acp-command";
+import { agentProfileSupportsSwitchLlmTool } from "#/api/agent-profiles-service/profile-field-support";
export const handle = { hideTitle: true };
type AgentType = "openhands" | "acp";
const ENABLE_SUB_AGENTS_FIELD_KEY = "enable_sub_agents";
+const ENABLE_SWITCH_LLM_TOOL_FIELD_KEY = "enable_switch_llm_tool";
const TOOL_CONCURRENCY_FIELD_KEY = "tool_concurrency_limit";
const COMMAND_PLACEHOLDER_FALLBACK = "npx -y <package-name>";
const ACP_CUSTOM_MODEL_KEY = "__custom_model__";
@@ -82,6 +84,14 @@ function getEnableSubAgentsValue(
return field?.default === true;
}
+function getEnableSwitchLlmToolValue(
+ settingsValue: unknown,
+ field: SettingsFieldSchema | undefined,
+) {
+ if (typeof settingsValue === "boolean") return settingsValue;
+ return field?.default === true;
+}
+
function isKnownAcpModel(
provider: ACPProviderConfig | undefined,
model: string,
@@ -99,6 +109,7 @@ export type AgentProfileFieldsDraft =
| {
agent_kind: "openhands";
enable_sub_agents: boolean;
+ enable_switch_llm_tool?: boolean;
tool_concurrency_limit?: number;
}
| {
@@ -119,6 +130,15 @@ export interface AgentProfileFieldsInput {
commandTokens: string[];
acpModel: string;
subAgentsEnabled: boolean;
+ switchLlmToolField?: SettingsFieldSchema;
+ switchLlmToolEnabled: boolean;
+ /**
+ * Whether the backend's *profile* model accepts `enable_switch_llm_tool`.
+ * Tracked apart from {@link switchLlmToolField} because the settings schema
+ * and the profile model gained the field in different releases — see
+ * {@link agentProfileSupportsSwitchLlmTool}.
+ */
+ switchLlmToolSupportedOnProfile: boolean;
toolConcurrencyField?: SettingsFieldSchema;
toolConcurrency: string | boolean;
}
@@ -151,6 +171,9 @@ export function buildAgentProfileFields(
commandTokens,
acpModel,
subAgentsEnabled,
+ switchLlmToolField,
+ switchLlmToolEnabled,
+ switchLlmToolSupportedOnProfile,
toolConcurrencyField,
toolConcurrency,
} = input;
@@ -172,6 +195,14 @@ export function buildAgentProfileFields(
agent_kind: "openhands",
enable_sub_agents: subAgentsEnabled,
};
+ if (switchLlmToolField && switchLlmToolSupportedOnProfile) {
+ // Two conditions, two different questions. The schema tells us the field
+ // is a real setting on this server; the version gate tells us its
+ // *profile* model will accept it. Between agent-server 1.29.0 and 1.30.x
+ // the first is true and the second is not, and the whole-profile
+ // overwrite is ``extra="forbid"`` — an unknown key 422s the entire save.
+ fields.enable_switch_llm_tool = switchLlmToolEnabled;
+ }
if (toolConcurrencyField) {
// Reuse the schema-driven coercion/validation; throws on bad input.
const coerced = coerceFieldValue(toolConcurrencyField, toolConcurrency);
@@ -261,6 +292,32 @@ export function AgentSettingsScreen({
initialSubAgentsEnabled,
);
+ // --- LLM switching tool (OpenHands path) ---
+ // Surfaced only when the backend schema exposes the field, so older
+ // agent-servers that predate ``enable_switch_llm_tool`` hide it cleanly.
+ const switchLlmToolField = fields?.find(
+ (field) => field.key === ENABLE_SWITCH_LLM_TOOL_FIELD_KEY,
+ );
+ const initialSwitchLlmToolEnabled = React.useMemo(
+ () =>
+ getEnableSwitchLlmToolValue(
+ agentSettingsSource?.[ENABLE_SWITCH_LLM_TOOL_FIELD_KEY],
+ switchLlmToolField,
+ ),
+ [switchLlmToolField, agentSettingsSource],
+ );
+ const [switchLlmToolEnabled, setSwitchLlmToolEnabled] = useState(
+ initialSwitchLlmToolEnabled,
+ );
+ // Embedded mode saves an AgentProfile, not global settings, and the profile
+ // model gained this field four releases after the settings schema did. The
+ // global page is unaffected — that endpoint has accepted the key since
+ // 1.22.0 — so the extra gate applies to the profile editor alone.
+ const switchLlmToolSupportedOnProfile = agentProfileSupportsSwitchLlmTool();
+ const showSwitchLlmTool =
+ Boolean(switchLlmToolField) &&
+ (!embedded || switchLlmToolSupportedOnProfile);
+
// --- Parallel tool calls (OpenHands path) ---
// Surfaced only when the backend schema exposes the field, so older
// agent-servers that predate ``tool_concurrency_limit`` hide it cleanly.
@@ -358,6 +415,11 @@ export function AgentSettingsScreen({
setSubAgentsEnabled(initialSubAgentsEnabled);
}, [initialSubAgentsEnabled]);
+ // Sync the LLM-switching toggle when settings reload
+ useEffect(() => {
+ setSwitchLlmToolEnabled(initialSwitchLlmToolEnabled);
+ }, [initialSwitchLlmToolEnabled]);
+
// Sync the parallel-tool-calls input when settings reload
useEffect(() => {
setToolConcurrency(initialToolConcurrency);
@@ -441,15 +503,19 @@ export function AgentSettingsScreen({
commandTokens,
acpModel,
subAgentsEnabled,
+ switchLlmToolField,
+ switchLlmToolEnabled,
+ switchLlmToolSupportedOnProfile,
toolConcurrencyField,
toolConcurrency,
});
- // Dirty tracking: for OpenHands path, also check sub-agents toggle and the
- // parallel-tool-calls input.
+ // Dirty tracking: for OpenHands path, also check the sub-agents and
+ // LLM-switching toggles and the parallel-tool-calls input.
const isOpenHandsDirty =
!isAcp &&
(subAgentsEnabled !== initialSubAgentsEnabled ||
+ switchLlmToolEnabled !== initialSwitchLlmToolEnabled ||
toolConcurrency !== initialToolConcurrency);
const settingsDirty = isDirty || isOpenHandsDirty;
// The single Save covers both the agent spec and ACP credentials, so it is
@@ -516,12 +582,20 @@ export function AgentSettingsScreen({
},
);
} else {
- // OpenHands path: save agent_kind + sub-agents toggle + parallel tool calls
+ // OpenHands path: save agent_kind + sub-agents toggle + the LLM-switching
+ // toggle + parallel tool calls
const agentSettingsDiff: Record<string, SettingsValue> = {
agent_kind: "openhands",
enable_sub_agents: subAgentsEnabled,
};
+ if (switchLlmToolField) {
+ // Schema-guarded like ``tool_concurrency_limit`` — older agent-servers
+ // that predate the field never receive the key.
+ agentSettingsDiff[ENABLE_SWITCH_LLM_TOOL_FIELD_KEY] =
+ switchLlmToolEnabled;
+ }
+
if (toolConcurrencyField) {
let coerced: SettingsValue;
try {
@@ -571,6 +645,22 @@ export function AgentSettingsScreen({
)
: t(I18nKey.SCHEMA$ENABLE_SUB_AGENTS$DESCRIPTION);
+ // LLM-switching field metadata for OpenHands section
+ const switchLlmToolLabel = switchLlmToolField
+ ? resolveSchemaFieldLabel(
+ t,
+ switchLlmToolField.key,
+ switchLlmToolField.label,
+ )
+ : t(I18nKey.SCHEMA$ENABLE_SWITCH_LLM_TOOL$LABEL);
+ const switchLlmToolDescription = switchLlmToolField
+ ? resolveSchemaFieldDescription(
+ t,
+ switchLlmToolField.key,
+ switchLlmToolField.description,
+ )
+ : t(I18nKey.SCHEMA$ENABLE_SWITCH_LLM_TOOL$DESCRIPTION);
+
return (
<div
data-testid="agent-settings-screen"
@@ -641,6 +731,30 @@ export function AgentSettingsScreen({
</div>
)}
+ {!isAcp && showSwitchLlmTool ? (
+ <div className="flex flex-col gap-1.5">
+ <SettingsSwitch
+ testId="agent-settings-enable-switch-llm-tool"
+ isToggled={switchLlmToolEnabled}
+ onToggle={(val) => {
+ setSwitchLlmToolEnabled(val);
+ }}
+ >
+ {switchLlmToolLabel}
+ </SettingsSwitch>
+ {switchLlmToolDescription ? (
+ <Typography.Paragraph
+ className={cn(
+ formControlSwitchDescriptionClassName,
+ "text-tertiary-alt text-xs leading-5",
+ )}
+ >
+ {switchLlmToolDescription}
+ </Typography.Paragraph>
+ ) : null}
+ </div>
+ ) : null}
+
{!isAcp && toolConcurrencyField ? (
<SchemaField
field={toolConcurrencyField}
diff --git a/src/services/settings.ts b/src/services/settings.ts
index 1844eb6f56..9f850f271e 100644
--- a/src/services/settings.ts
+++ b/src/services/settings.ts
@@ -48,6 +48,7 @@ export const DEFAULT_SETTINGS: Settings = {
enable_iterative_refinement: false,
},
enable_sub_agents: false,
+ enable_switch_llm_tool: true,
mcp_config: {},
},
conversation_settings_schema: null,