Skip to content

🙌 OpenHands: AI-Driven Development

Fix sub-agent settings and built-in registration (#14418)

Xingyao Wangbe9afb76720f
diff --git a/frontend/__tests__/components/shared/modals/settings/settings-form.test.tsx b/frontend/__tests__/components/shared/modals/settings/settings-form.test.tsx
index ab478f7803..bcab7cf256 100644
--- a/frontend/__tests__/components/shared/modals/settings/settings-form.test.tsx
+++ b/frontend/__tests__/components/shared/modals/settings/settings-form.test.tsx
@@ -1,8 +1,7 @@
-import userEvent from "@testing-library/user-event";
-import { describe, expect, it, vi } from "vitest";
+import { beforeEach, describe, expect, it, vi } from "vitest";
import { renderWithProviders } from "test-utils";
import { createRoutesStub } from "react-router";
-import { screen, waitFor } from "@testing-library/react";
+import { fireEvent, screen, waitFor } from "@testing-library/react";
import SettingsService from "#/api/settings-service/settings-service.api";
import { SettingsForm } from "#/components/shared/modals/settings/settings-form";
import { DEFAULT_SETTINGS } from "#/services/settings";
@@ -21,12 +20,21 @@ describe("SettingsForm", () => {
},
]);
+ beforeEach(() => {
+ vi.clearAllMocks();
+ saveSettingsSpy.mockResolvedValue(true);
+ });
+
it("should save the user settings and close the modal when the form is submitted", async () => {
- const user = userEvent.setup();
renderWithProviders(<RouteStub />);
- const saveButton = screen.getByRole("button", { name: /save/i });
- await user.click(saveButton);
+ await waitFor(() =>
+ expect(screen.getByTestId("llm-model-input")).toHaveValue(
+ "claude-opus-4-5-20251101",
+ ),
+ );
+
+ fireEvent.submit(screen.getByTestId("settings-form"));
await waitFor(() =>
expect(saveSettingsSpy).toHaveBeenCalledWith(
@@ -39,5 +47,6 @@ describe("SettingsForm", () => {
}),
),
);
+ await waitFor(() => expect(onCloseMock).toHaveBeenCalled());
});
});
diff --git a/frontend/__tests__/routes/manage-org.test.tsx b/frontend/__tests__/routes/manage-org.test.tsx
index 5a37bcd8ad..4e00aa3a9a 100644
--- a/frontend/__tests__/routes/manage-org.test.tsx
+++ b/frontend/__tests__/routes/manage-org.test.tsx
@@ -246,7 +246,9 @@ describe("Manage Org Route", () => {
await userEvent.click(nextButton);
// expect redirect to payment page
- expect(createCheckoutSessionSpy).toHaveBeenCalledWith(1000);
+ await waitFor(() =>
+ expect(createCheckoutSessionSpy).toHaveBeenCalledWith(1000),
+ );
await waitFor(() =>
expect(screen.queryByTestId("add-credits-form")).not.toBeInTheDocument(),
diff --git a/frontend/src/constants/settings-nav.tsx b/frontend/src/constants/settings-nav.tsx
index e2f34d1b8c..88b2d00019 100644
--- a/frontend/src/constants/settings-nav.tsx
+++ b/frontend/src/constants/settings-nav.tsx
@@ -4,6 +4,7 @@ import KeyIcon from "#/icons/key.svg?react";
import LightbulbIcon from "#/icons/lightbulb.svg?react";
import LockIcon from "#/icons/lock.svg?react";
import MemoryIcon from "#/icons/memory_icon.svg?react";
+import RobotIcon from "#/icons/u-robot.svg?react";
import ServerProcessIcon from "#/icons/server-process.svg?react";
import SettingsGearIcon from "#/icons/settings-gear.svg?react";
import CircuitIcon from "#/icons/u-circuit.svg?react";
@@ -61,6 +62,12 @@ export const SAAS_NAV_ITEMS: SettingsNavItem[] = [
text: "COMMON$LANGUAGE_MODEL_LLM",
section: "personal",
},
+ {
+ icon: <RobotIcon width={22} height={22} />,
+ to: "/settings/agent",
+ text: "SETTINGS$AGENT",
+ section: "personal",
+ },
{
icon: <MemoryIcon width={22} height={22} />,
to: "/settings/condenser",
@@ -129,6 +136,11 @@ export const OSS_NAV_ITEMS: SettingsNavItem[] = [
to: "/settings",
text: "SETTINGS$NAV_LLM",
},
+ {
+ icon: <RobotIcon width={22} height={22} />,
+ to: "/settings/agent",
+ text: "SETTINGS$AGENT",
+ },
{
icon: <MemoryIcon width={22} height={22} />,
to: "/settings/condenser",
diff --git a/frontend/src/hooks/organizations/use-git-conversation-routing.ts b/frontend/src/hooks/organizations/use-git-conversation-routing.ts
index c684e44b49..a3482e547e 100644
--- a/frontend/src/hooks/organizations/use-git-conversation-routing.ts
+++ b/frontend/src/hooks/organizations/use-git-conversation-routing.ts
@@ -28,14 +28,16 @@ export function useGitConversationRouting() {
const orgs = React.useMemo<GitOrg[]>(() => {
if (!userGitOrgs) return [];
+ const claimList = Array.isArray(claims) ? claims : [];
+ const orgNames = Array.isArray(userGitOrgs.organizations)
+ ? userGitOrgs.organizations
+ : [];
+
const claimMap = new Map(
- (claims ?? []).map((c) => [
- buildOrgId(c.provider, c.git_organization),
- c,
- ]),
+ claimList.map((c) => [buildOrgId(c.provider, c.git_organization), c]),
);
- return userGitOrgs.organizations.map((name) => {
+ return orgNames.map((name) => {
const id = buildOrgId(userGitOrgs.provider, name);
const claim = claimMap.get(id);
diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.ts
index 44e744d06a..3d925406be 100644
--- a/frontend/src/i18n/declaration.ts
+++ b/frontend/src/i18n/declaration.ts
@@ -126,6 +126,8 @@ export enum I18nKey {
SETTINGS$SDK_SCHEMA_UNAVAILABLE = "SETTINGS$SDK_SCHEMA_UNAVAILABLE",
SCHEMA$AGENT$DESCRIPTION = "SCHEMA$AGENT$DESCRIPTION",
SCHEMA$AGENT$LABEL = "SCHEMA$AGENT$LABEL",
+ SCHEMA$ENABLE_SUB_AGENTS$DESCRIPTION = "SCHEMA$ENABLE_SUB_AGENTS$DESCRIPTION",
+ SCHEMA$ENABLE_SUB_AGENTS$LABEL = "SCHEMA$ENABLE_SUB_AGENTS$LABEL",
SCHEMA$CONDENSER$ENABLED$DESCRIPTION = "SCHEMA$CONDENSER$ENABLED$DESCRIPTION",
SCHEMA$CONDENSER$ENABLED$LABEL = "SCHEMA$CONDENSER$ENABLED$LABEL",
SCHEMA$CONDENSER$MAX_SIZE$DESCRIPTION = "SCHEMA$CONDENSER$MAX_SIZE$DESCRIPTION",
diff --git a/frontend/src/i18n/translation.json b/frontend/src/i18n/translation.json
index d84f0457db..cb82cd0693 100644
--- a/frontend/src/i18n/translation.json
+++ b/frontend/src/i18n/translation.json
@@ -2141,6 +2141,40 @@
"uk": "Агент",
"ca": "Agent"
},
+ "SCHEMA$ENABLE_SUB_AGENTS$DESCRIPTION": {
+ "en": "Enable sub-agent delegation via TaskToolSet.",
+ "ja": "TaskToolSet を介したサブエージェントへの委任を有効にします。",
+ "zh-CN": "通过 TaskToolSet 启用子智能体委派。",
+ "zh-TW": "透過 TaskToolSet 啟用子智能體委派。",
+ "ko-KR": "TaskToolSet을 통한 하위 에이전트 위임을 활성화합니다.",
+ "no": "Aktiver delegering til underagenter via TaskToolSet.",
+ "it": "Abilita la delega ai sottoagenti tramite TaskToolSet.",
+ "pt": "Ative a delegação para subagentes via TaskToolSet.",
+ "es": "Habilita la delegación a subagentes mediante TaskToolSet.",
+ "ar": "مكّن تفويض المهام إلى الوكلاء الفرعيين عبر TaskToolSet.",
+ "fr": "Activez la délégation aux sous-agents via TaskToolSet.",
+ "tr": "TaskToolSet aracılığıyla alt ajanlara yetki devrini etkinleştirin.",
+ "de": "Aktivieren Sie die Delegierung an Sub-Agenten über TaskToolSet.",
+ "uk": "Увімкніть делегування субагентам через TaskToolSet.",
+ "ca": "Activa la delegació a subagents mitjançant TaskToolSet."
+ },
+ "SCHEMA$ENABLE_SUB_AGENTS$LABEL": {
+ "en": "Enable sub-agents",
+ "ja": "サブエージェントを有効にする",
+ "zh-CN": "启用子智能体",
+ "zh-TW": "啟用子智能體",
+ "ko-KR": "하위 에이전트 활성화",
+ "no": "Aktiver underagenter",
+ "it": "Abilita sottoagenti",
+ "pt": "Ativar subagentes",
+ "es": "Habilitar subagentes",
+ "ar": "تمكين الوكلاء الفرعيين",
+ "fr": "Activer les sous-agents",
+ "tr": "Alt ajanları etkinleştir",
+ "de": "Sub-Agenten aktivieren",
+ "uk": "Увімкнути субагентів",
+ "ca": "Activa subagents"
+ },
"SCHEMA$CONDENSER$ENABLED$DESCRIPTION": {
"en": "Enable the LLM summarizing condenser.",
"ja": "LLM要約コンデンサーを有効にします。",
diff --git a/frontend/src/mocks/settings-handlers.ts b/frontend/src/mocks/settings-handlers.ts
index 184f422633..ac52113279 100644
--- a/frontend/src/mocks/settings-handlers.ts
+++ b/frontend/src/mocks/settings-handlers.ts
@@ -80,6 +80,29 @@ const MOCK_AGENT_SETTINGS_SCHEMA: NonNullable<
> = {
model_name: "AgentSettings",
sections: [
+ // Mirrors the SDK schema; the OpenHands UI displays this field on its
+ // dedicated Agent settings page by key.
+ {
+ key: "general",
+ label: "General",
+ fields: [
+ {
+ key: "enable_sub_agents",
+ label: "Enable sub-agents",
+ description:
+ "Allow the agent to delegate work to specialized built-in sub-agents.",
+ section: "general",
+ section_label: "General",
+ value_type: "boolean",
+ default: false,
+ choices: [],
+ depends_on: [],
+ prominence: "major",
+ secret: false,
+ required: false,
+ },
+ ],
+ },
{
key: "llm",
label: "LLM",
@@ -355,6 +378,7 @@ export const MOCK_DEFAULT_USER_SETTINGS: Settings = {
api_key: null,
model: DEFAULT_MODEL,
},
+ enable_sub_agents: false,
},
conversation_settings_schema: MOCK_CONVERSATION_SETTINGS_SCHEMA,
conversation_settings: {
diff --git a/frontend/src/routes.ts b/frontend/src/routes.ts
index a006d15fc9..723135b80c 100644
--- a/frontend/src/routes.ts
+++ b/frontend/src/routes.ts
@@ -15,6 +15,7 @@ export default [
route("launch", "routes/launch.tsx"),
route("settings", "routes/settings.tsx", [
index("routes/llm-settings.tsx"),
+ route("agent", "routes/agent-settings.tsx"),
route("condenser", "routes/condenser-settings.tsx"),
route("verification", "routes/verification-settings.tsx"),
route("org-defaults", "routes/org-default-llm-settings.tsx"),
diff --git a/frontend/src/routes/agent-settings.tsx b/frontend/src/routes/agent-settings.tsx
new file mode 100644
index 0000000000..1b8959f4ef
--- /dev/null
+++ b/frontend/src/routes/agent-settings.tsx
@@ -0,0 +1,155 @@
+import React from "react";
+import { AxiosError } from "axios";
+import { useTranslation } from "react-i18next";
+import { BrandButton } from "#/components/features/settings/brand-button";
+import { LlmSettingsInputsSkeleton } from "#/components/features/settings/llm-settings/llm-settings-inputs-skeleton";
+import { SettingsSwitch } from "#/components/features/settings/settings-switch";
+import { useSaveSettings } from "#/hooks/mutation/use-save-settings";
+import { useAgentSettingsSchema } from "#/hooks/query/use-agent-settings-schema";
+import { useSettings } from "#/hooks/query/use-settings";
+import { I18nKey } from "#/i18n/declaration";
+import { SettingsFieldSchema } from "#/types/settings";
+import { Typography } from "#/ui/typography";
+import {
+ displayErrorToast,
+ displaySuccessToast,
+} from "#/utils/custom-toast-handlers";
+import { createPermissionGuard } from "#/utils/org/permission-guard";
+import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";
+import {
+ resolveSchemaFieldDescription,
+ resolveSchemaFieldLabel,
+} from "#/utils/sdk-settings-field-metadata";
+
+const ENABLE_SUB_AGENTS_FIELD_KEY = "enable_sub_agents";
+
+function findEnableSubAgentsField(
+ fields: SettingsFieldSchema[] | undefined,
+): SettingsFieldSchema | undefined {
+ return fields?.find((field) => field.key === ENABLE_SUB_AGENTS_FIELD_KEY);
+}
+
+function getEnableSubAgentsValue(
+ settingsValue: unknown,
+ field: SettingsFieldSchema | undefined,
+) {
+ if (typeof settingsValue === "boolean") {
+ return settingsValue;
+ }
+
+ return field?.default === true;
+}
+
+export const clientLoader = createPermissionGuard("view_llm_settings");
+
+export default function AgentSettingsScreen() {
+ const { t } = useTranslation();
+ const { mutate: saveSettings, isPending } = useSaveSettings();
+ const { data: settings, isLoading: isSettingsLoading } = useSettings();
+ const { data: schema, isLoading: isSchemaLoading } = useAgentSettingsSchema(
+ settings?.agent_settings_schema,
+ );
+
+ const fields = React.useMemo(
+ () => schema?.sections.flatMap((section) => section.fields),
+ [schema],
+ );
+ const field = findEnableSubAgentsField(fields);
+ const initialIsEnabled = React.useMemo(
+ () =>
+ getEnableSubAgentsValue(
+ settings?.agent_settings?.[ENABLE_SUB_AGENTS_FIELD_KEY],
+ field,
+ ),
+ [field, settings?.agent_settings],
+ );
+ const [isEnabled, setIsEnabled] = React.useState(initialIsEnabled);
+
+ React.useEffect(() => {
+ setIsEnabled(initialIsEnabled);
+ }, [initialIsEnabled]);
+
+ const isDirty = isEnabled !== initialIsEnabled;
+
+ const handleError = React.useCallback(
+ (error: AxiosError) => {
+ const msg = retrieveAxiosErrorMessage(error);
+ displayErrorToast(msg || t(I18nKey.ERROR$GENERIC));
+ },
+ [t],
+ );
+
+ const handleSave = () => {
+ if (!isDirty) return;
+
+ saveSettings(
+ {
+ agent_settings_diff: {
+ enable_sub_agents: isEnabled,
+ },
+ },
+ {
+ onError: handleError,
+ onSuccess: () => {
+ displaySuccessToast(t(I18nKey.SETTINGS$SAVED_WARNING));
+ },
+ },
+ );
+ };
+
+ if (isSettingsLoading || isSchemaLoading) {
+ return <LlmSettingsInputsSkeleton />;
+ }
+
+ if (!field) {
+ return (
+ <Typography.Paragraph className="text-tertiary-alt">
+ {t(I18nKey.SETTINGS$SDK_SCHEMA_UNAVAILABLE)}
+ </Typography.Paragraph>
+ );
+ }
+
+ const label = resolveSchemaFieldLabel(t, field.key, field.label);
+ const description = resolveSchemaFieldDescription(
+ t,
+ field.key,
+ field.description,
+ );
+
+ return (
+ <div data-testid="agent-settings-screen" className="h-full relative">
+ <div className="flex flex-col gap-8 pb-20">
+ <section className="grid gap-4 xl:grid-cols-2">
+ <div className="flex flex-col gap-1.5">
+ <SettingsSwitch
+ testId="agent-settings-enable-sub-agents"
+ isToggled={isEnabled}
+ onToggle={setIsEnabled}
+ >
+ {label}
+ </SettingsSwitch>
+ {description ? (
+ <Typography.Paragraph className="text-tertiary-alt text-xs leading-5">
+ {description}
+ </Typography.Paragraph>
+ ) : null}
+ </div>
+ </section>
+ </div>
+
+ <div className="sticky bottom-0 bg-base py-4">
+ <BrandButton
+ testId="save-button"
+ type="button"
+ variant="primary"
+ isDisabled={isPending || !isDirty}
+ onClick={handleSave}
+ >
+ {isPending
+ ? t(I18nKey.SETTINGS$SAVING)
+ : t(I18nKey.SETTINGS$SAVE_CHANGES)}
+ </BrandButton>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/services/settings.ts b/frontend/src/services/settings.ts
index 1d159e0760..399de03da9 100644
--- a/frontend/src/services/settings.ts
+++ b/frontend/src/services/settings.ts
@@ -51,6 +51,7 @@ export const DEFAULT_SETTINGS: Settings = {
critic_enabled: false,
enable_iterative_refinement: false,
},
+ enable_sub_agents: false,
mcp_config: {
sse_servers: [],
stdio_servers: [],
diff --git a/openhands/app_server/app_conversation/live_status_app_conversation_service.py b/openhands/app_server/app_conversation/live_status_app_conversation_service.py
index ab78e729ce..285279ba73 100644
--- a/openhands/app_server/app_conversation/live_status_app_conversation_service.py
+++ b/openhands/app_server/app_conversation/live_status_app_conversation_service.py
@@ -102,6 +102,7 @@ from openhands.sdk.llm import LLM
from openhands.sdk.plugin import PluginSource
from openhands.sdk.secret import LookupSecret, StaticSecret
from openhands.sdk.settings import ACPAgentSettings
+from openhands.sdk.subagent import get_registered_agent_definitions
from openhands.sdk.utils.paging import page_iterator
from openhands.sdk.utils.redact import (
redact_api_key_literals,
@@ -111,6 +112,7 @@ from openhands.sdk.utils.redact import (
from openhands.sdk.workspace.remote.async_remote_workspace import AsyncRemoteWorkspace
from openhands.tools.preset.default import (
get_default_tools,
+ register_builtins_agents,
)
from openhands.tools.preset.planning import (
format_plan_structure,
@@ -1366,16 +1368,20 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
effective_suffix = web_host_context
# --- tools ----------------------------------------------------------
+ agent_definitions: list[Any] = []
if agent_type == AgentType.PLAN:
plan_path = None
if project_dir:
plan_path = self._compute_plan_path(project_dir, git_provider)
tools = get_planning_tools(plan_path=plan_path)
else:
+ register_builtins_agents(enable_browser=True)
tools = get_default_tools(
enable_browser=True,
enable_sub_agents=user.agent_settings.enable_sub_agents,
)
+ if user.agent_settings.enable_sub_agents:
+ agent_definitions = list(get_registered_agent_definitions())
# --- build AgentSettings and create agent ---------------------------
from fastmcp.mcp_config import MCPConfig
@@ -1450,6 +1456,7 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
'workspace': workspace,
'conversation_id': conversation_id,
'initial_message': final_initial_message,
+ 'agent_definitions': agent_definitions,
'plugins': sdk_plugins,
'hook_config': hook_config,
}
diff --git a/openhands/app_server/sandbox/process_sandbox_spec_service.py b/openhands/app_server/sandbox/process_sandbox_spec_service.py
index fed35399c9..91c1f787cc 100644
--- a/openhands/app_server/sandbox/process_sandbox_spec_service.py
+++ b/openhands/app_server/sandbox/process_sandbox_spec_service.py
@@ -24,11 +24,14 @@ def get_default_sandbox_specs():
id=get_agent_server_image(),
command=['python', '-m', 'openhands.agent_server'],
initial_env={
+ # Keep tmux sockets on a short path; macOS default temp dirs can
+ # exceed Unix socket path limits once libtmux appends tmux-UID.
+ 'TMUX_TMPDIR': '/tmp/openhands-tmux',
# VSCode disabled for now
'OH_ENABLE_VS_CODE': '0',
**get_agent_server_env(),
},
- working_dir='',
+ working_dir='.',
)
]
diff --git a/tests/unit/app_server/test_agent_server_env_override.py b/tests/unit/app_server/test_agent_server_env_override.py
index 9b05b33a54..efd2b7a6fc 100644
--- a/tests/unit/app_server/test_agent_server_env_override.py
+++ b/tests/unit/app_server/test_agent_server_env_override.py
@@ -476,6 +476,7 @@ class TestProcessSandboxSpecEnvironmentOverride:
# Should only have the default environment variables
expected_defaults = {
'OH_ENABLE_VS_CODE',
+ 'TMUX_TMPDIR',
}
# All defaults should be present
@@ -484,6 +485,8 @@ class TestProcessSandboxSpecEnvironmentOverride:
# Should have exactly the expected variables
assert set(spec.initial_env.keys()) == expected_defaults
+ assert spec.initial_env['TMUX_TMPDIR'] == '/tmp/openhands-tmux'
+ assert spec.working_dir == '.'
class TestRemoteSandboxSpecEnvironmentOverride:
diff --git a/tests/unit/app_server/test_live_status_app_conversation_service.py b/tests/unit/app_server/test_live_status_app_conversation_service.py
index 014dfa89e4..02de59e12b 100644
--- a/tests/unit/app_server/test_live_status_app_conversation_service.py
+++ b/tests/unit/app_server/test_live_status_app_conversation_service.py
@@ -940,14 +940,30 @@ class TestLiveStatusAppConversationService:
self.mock_user, 'gpt-4', test_conversation_id
)
+ @patch(
+ 'openhands.app_server.app_conversation.live_status_app_conversation_service.get_registered_agent_definitions'
+ )
+ @patch(
+ 'openhands.app_server.app_conversation.live_status_app_conversation_service.register_builtins_agents'
+ )
@patch(
'openhands.app_server.app_conversation.live_status_app_conversation_service.get_default_tools',
return_value=[],
)
@pytest.mark.asyncio
- async def test_build_request_passes_enable_sub_agents_true(self, mock_tools):
- """get_default_tools receives enable_sub_agents=True when the user setting is on."""
+ async def test_build_request_passes_enable_sub_agents_true(
+ self, mock_tools, mock_register_builtins, mock_get_agent_definitions
+ ):
+ """Built-in sub-agents are registered when the user setting is on."""
from openhands.sdk.settings import OpenHandsAgentSettings
+ from openhands.sdk.subagent.schema import AgentDefinition
+
+ agent_definition = AgentDefinition(
+ name='general-purpose',
+ description='General-purpose subagent',
+ tools=['terminal'],
+ )
+ mock_get_agent_definitions.return_value = [agent_definition]
agent_settings = OpenHandsAgentSettings(
llm={'model': 'gpt-4', 'api_key': 'test-key'},
@@ -960,7 +976,7 @@ class TestLiveStatusAppConversationService:
self.service._setup_secrets_for_git_providers = AsyncMock(return_value={})
self.service._configure_llm_and_mcp = AsyncMock(return_value=(real_llm, {}))
- await self.service._build_start_conversation_request_for_user(
+ result = await self.service._build_start_conversation_request_for_user(
sandbox=self.mock_sandbox,
conversation_id=uuid4(),
initial_message=None,
@@ -970,15 +986,26 @@ class TestLiveStatusAppConversationService:
remote_workspace=None,
)
+ mock_register_builtins.assert_called_once_with(enable_browser=True)
+ mock_get_agent_definitions.assert_called_once_with()
mock_tools.assert_called_once_with(enable_browser=True, enable_sub_agents=True)
+ assert result.agent_definitions == [agent_definition]
+ @patch(
+ 'openhands.app_server.app_conversation.live_status_app_conversation_service.get_registered_agent_definitions'
+ )
+ @patch(
+ 'openhands.app_server.app_conversation.live_status_app_conversation_service.register_builtins_agents'
+ )
@patch(
'openhands.app_server.app_conversation.live_status_app_conversation_service.get_default_tools',
return_value=[],
)
@pytest.mark.asyncio
- async def test_build_request_passes_enable_sub_agents_false(self, mock_tools):
- """get_default_tools receives enable_sub_agents=False when the user setting is off."""
+ async def test_build_request_passes_enable_sub_agents_false(
+ self, mock_tools, mock_register_builtins, mock_get_agent_definitions
+ ):
+ """Built-in sub-agents are registered but not forwarded when disabled."""
from openhands.sdk.settings import OpenHandsAgentSettings
agent_settings = OpenHandsAgentSettings(
@@ -992,7 +1019,7 @@ class TestLiveStatusAppConversationService:
self.service._setup_secrets_for_git_providers = AsyncMock(return_value={})
self.service._configure_llm_and_mcp = AsyncMock(return_value=(real_llm, {}))
- await self.service._build_start_conversation_request_for_user(
+ result = await self.service._build_start_conversation_request_for_user(
sandbox=self.mock_sandbox,
conversation_id=uuid4(),
initial_message=None,
@@ -1002,7 +1029,10 @@ class TestLiveStatusAppConversationService:
remote_workspace=None,
)
+ mock_register_builtins.assert_called_once_with(enable_browser=True)
+ mock_get_agent_definitions.assert_not_called()
mock_tools.assert_called_once_with(enable_browser=True, enable_sub_agents=False)
+ assert result.agent_definitions == []
@patch(
'openhands.app_server.app_conversation.live_status_app_conversation_service.get_default_tools',
diff --git a/tests/unit/app_server/test_settings_api.py b/tests/unit/app_server/test_settings_api.py
index 11ec5d1227..35e570e9d0 100644
--- a/tests/unit/app_server/test_settings_api.py
+++ b/tests/unit/app_server/test_settings_api.py
@@ -117,6 +117,9 @@ def test_get_agent_settings_schema_includes_critic_verification_fields(test_clie
assert response.status_code == 200
schema = response.json()
section_keys = [s['key'] for s in schema['sections']]
+ general_section = next(s for s in schema['sections'] if s['key'] == 'general')
+ general_field_keys = [f['key'] for f in general_section['fields']]
+ assert 'enable_sub_agents' in general_field_keys
assert 'verification' in section_keys
section = next(s for s in schema['sections'] if s['key'] == 'verification')
field_keys = [f['key'] for f in section['fields']]