Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(agent-profiles): keep the `default` rules local and save home LLM picks on Cloud (#18747)

simonrosenberg12026be8181b
diff --git a/.pr/cloud-default-profile/editor.png b/.pr/cloud-default-profile/editor.png
new file mode 100644
index 0000000000..f7c7a27ce9
Binary files /dev/null and b/.pr/cloud-default-profile/editor.png differ
diff --git a/.pr/cloud-default-profile/home-pick.png b/.pr/cloud-default-profile/home-pick.png
new file mode 100644
index 0000000000..a15606925d
Binary files /dev/null and b/.pr/cloud-default-profile/home-pick.png differ
diff --git a/.pr/cloud-default-profile/repro.mjs b/.pr/cloud-default-profile/repro.mjs
new file mode 100644
index 0000000000..afbe0d006b
--- /dev/null
+++ b/.pr/cloud-default-profile/repro.mjs
@@ -0,0 +1,233 @@
+// usage: QA_MODE=before|after [QA_DRYRUN=1] [QA_STEPS=s1,s2,s3] node .tmp/qa-cloud/repro.mjs
+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import { chromium } from "playwright";
+
+const FRONT = process.env.QA_FRONT ?? "http://127.0.0.1:18711";
+const HOST = "https://app.shared-8.replicated.all-hands-testing.dev";
+const KEY = readFileSync(`${process.env.HOME}/.oh-fleet-shared8-key`, "utf8").trim();
+const ORG = "b6f2a99b-68fa-40fa-b28b-07f38ca733e3";
+const MODE = process.env.QA_MODE ?? "before";
+const DRY = !!process.env.QA_DRYRUN;
+const STEPS = (process.env.QA_STEPS ?? "s1,s2,s3").split(",");
+const OUT = `${process.env.QA_OUT ?? ".tmp/qa-cloud/out"}/${MODE}${DRY ? "-dry" : ""}`;
+mkdirSync(OUT, { recursive: true });
+
+async function api(method, path, body) {
+ const res = await fetch(`${HOST}${path}`, {
+ method,
+ headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
+ body: body === undefined ? undefined : JSON.stringify(body),
+ });
+ const text = await res.text();
+ let json = text;
+ try {
+ json = JSON.parse(text);
+ } catch {}
+ return { status: res.status, body: json };
+}
+const agentProfile = async (name) => (await api("GET", `/api/agent-profiles/${name}`)).body.profile;
+const agentProfiles = async () => (await api("GET", "/api/agent-profiles")).body;
+const orgActiveLlm = async () => (await api("GET", `/api/organizations/${ORG}/profiles`)).body.active_profile;
+const activateAgent = async (name) => {
+ const { profiles } = await agentProfiles();
+ return api("POST", `/api/agent-profiles/${profiles.find((p) => p.name === name).id}/activate`, {});
+};
+
+async function reset(active) {
+ await api("POST", "/api/agent-profiles/default", { agent_kind: "openhands", llm_profile_ref: "qa-alpha", mcp_server_refs: [], secret_refs: [] });
+ await api("POST", "/api/agent-profiles/qa-reviewer", { agent_kind: "openhands", llm_profile_ref: "qa-alpha" });
+ await api("POST", `/api/organizations/${ORG}/profiles/qa-beta/activate`, {});
+ await activateAgent(active);
+}
+
+const results = [];
+function record(name, info) {
+ results.push({ name, ...info });
+ console.log(`${name}: ${JSON.stringify(info)}`);
+}
+
+const requests = [];
+const starts = [];
+const blocked = [];
+async function intercept(context) {
+ await context.route("**/*", async (route) => {
+ const req = route.request();
+ const url = new URL(req.url());
+ if (url.origin === HOST) requests.push(`${req.method()} ${url.pathname}`);
+ if (req.method() !== "POST" || url.origin !== HOST) return route.continue();
+ let body = {};
+ try {
+ body = req.postDataJSON() ?? {};
+ } catch {}
+ if (/^\/api\/v1\/app-conversations\/?$/.test(url.pathname)) {
+ const entry = { agent_profile_id: body.agent_profile_id ?? null, llm_model: body.llm_model ?? null, had_message: !!body.initial_message };
+ starts.push(entry);
+ if (DRY) {
+ entry.response = { status: 503, dryRun: true };
+ return route.fulfill({ status: 503, contentType: "application/json", body: JSON.stringify({ detail: "QA dry run" }) });
+ }
+ const response = await route.fetch({ postData: JSON.stringify({ ...body, initial_message: null }) });
+ let json = null;
+ try {
+ json = await response.json();
+ } catch {}
+ entry.response = { status: response.status(), id: json?.id ?? null };
+ return route.fulfill({ response });
+ }
+ if (/(\/events|\/messages|pending-messages|\/run|\/ask_agent|\/generate_title)\/?$/.test(url.pathname)) {
+ blocked.push(url.pathname);
+ return route.fulfill({ status: 503, contentType: "application/json", body: JSON.stringify({ detail: "blocked by QA: no model calls" }) });
+ }
+ return route.continue();
+ });
+}
+
+async function waitStart(taskId, timeoutS = 300) {
+ for (let i = 0; i < timeoutS / 5; i++) {
+ const t = (await api("GET", `/api/v1/app-conversations/start-tasks?ids=${taskId}`)).body?.[0];
+ if (t && (t.status === "READY" || t.status === "ERROR")) return t;
+ await new Promise((r) => setTimeout(r, 5000));
+ }
+ return null;
+}
+async function pauseSandbox(conversationId) {
+ const sandbox = (await api("GET", `/api/v1/app-conversations?ids=${conversationId}`)).body?.[0]?.sandbox_id;
+ if (sandbox) await api("POST", `/api/v1/sandboxes/${sandbox}/pause`);
+ return sandbox ?? null;
+}
+
+async function gotoHome(page) {
+ await page.goto(`${FRONT}/`, { waitUntil: "domcontentloaded" });
+ await page.getByTestId("home-chat-launcher").waitFor({ timeout: 60_000 });
+ await page.getByTestId("chat-input-llm-profile").waitFor({ timeout: 60_000 });
+ await page.waitForTimeout(3000);
+}
+const pills = async (page) => ({
+ agent: (await page.getByTestId("chat-input-agent-profile").count()) ? (await page.getByTestId("chat-input-agent-profile").innerText()).trim() : null,
+ llm: await page.getByTestId("chat-input-llm-profile").getAttribute("title"),
+});
+async function pickLlm(page, name, shot) {
+ await page.getByTestId("chat-input-llm-profile").click();
+ await page.getByTestId(`chat-input-llm-profile-option-${name}`).waitFor({ timeout: 15_000 });
+ await page.screenshot({ path: `${OUT}/${shot}` });
+ await page.getByTestId(`chat-input-llm-profile-option-${name}`).click();
+ await page.waitForTimeout(4000);
+}
+async function launchFromHome(page) {
+ const n = starts.length;
+ await page.getByTestId("chat-input").waitFor({ state: "visible", timeout: 60_000 });
+ await page.evaluate(() => {
+ const el = document.querySelector('[data-testid="chat-input"]');
+ el.focus();
+ el.textContent = "QA cloud repro launch";
+ el.dispatchEvent(new InputEvent("input", { bubbles: true, data: "QA cloud repro launch", inputType: "insertText" }));
+ });
+ await page.getByTestId("submit-button").click();
+ for (let i = 0; i < 60 && !starts[n]?.response; i++) await page.waitForTimeout(500);
+ return starts[n] ?? null;
+}
+
+const browser = await chromium.launch();
+const context = await browser.newContext({ viewport: { width: 1280, height: 860 } });
+await context.addInitScript(() => {
+ window.localStorage.setItem("analytics-consent", "false");
+ window.localStorage.setItem("openhands-telemetry-consent", "denied");
+ window.localStorage.setItem("openhands-telemetry-first-use", "true");
+ window.localStorage.setItem("openhands-onboarded", "1");
+});
+await intercept(context);
+const page = await context.newPage();
+const consoleErrors = [];
+page.on("console", (m) => {
+ if (m.type() === "error") consoleErrors.push(m.text().slice(0, 300));
+});
+
+try {
+ await page.goto(`${FRONT}/`, { waitUntil: "domcontentloaded" });
+ await page.waitForTimeout(3000);
+ await page.evaluate(
+ ({ HOST, KEY, ORG }) => {
+ const backends = JSON.parse(window.localStorage.getItem("openhands-backends") || "[]").filter((b) => b.id !== "qa-cloud");
+ backends.push({ id: "qa-cloud", name: "shared-8", host: HOST, apiKey: KEY, kind: "cloud" });
+ window.localStorage.setItem("openhands-backends", JSON.stringify(backends));
+ window.localStorage.setItem("openhands-active-backend", JSON.stringify({ backendId: "qa-cloud", orgId: ORG }));
+ window.sessionStorage.removeItem("openhands-active-backend");
+ },
+ { HOST, KEY, ORG },
+ );
+
+ if (STEPS.includes("s1")) {
+ // `default` is active with its own LLM qa-alpha; the org's active LLM is qa-beta.
+ await reset("default");
+ await gotoHome(page);
+ const shown = await pills(page);
+ await page.screenshot({ path: `${OUT}/s1-home.png` });
+ await pickLlm(page, "qa-gamma", "s1-menu.png");
+ const afterPick = await pills(page);
+ await page.screenshot({ path: `${OUT}/s1-after-pick.png` });
+ const state = { defaultRef: (await agentProfile("default")).llm_profile_ref, orgActive: await orgActiveLlm() };
+ const start = await launchFromHome(page);
+ let ran = null;
+ if (start?.response?.id) {
+ const task = await waitStart(start.response.id);
+ const conv = task?.app_conversation_id ? (await api("GET", `/api/v1/app-conversations?ids=${task.app_conversation_id}`)).body?.[0] : null;
+ ran = { status: task?.status ?? "timeout", detail: task?.detail ?? null, llm_model: conv?.llm_model ?? null, launched: conv?.launched_agent_profile ?? null };
+ if (task?.app_conversation_id) ran.pausedSandbox = await pauseSandbox(task.app_conversation_id);
+ }
+ record("s1 default on home", { shown, afterPick, state, start, ran });
+ }
+
+ if (STEPS.includes("s2")) {
+ // A named profile is active with qa-alpha.
+ await reset("qa-reviewer");
+ await gotoHome(page);
+ const shown = await pills(page);
+ const before = requests.length;
+ await pickLlm(page, "qa-beta", "s2-menu.png");
+ const writes = requests.slice(before).filter((r) => r.startsWith("POST"));
+ await gotoHome(page);
+ const afterReload = await pills(page);
+ await page.screenshot({ path: `${OUT}/s2-after-reload.png` });
+ record("s2 named profile on home", { shown, writes, afterReload, reviewerRef: (await agentProfile("qa-reviewer")).llm_profile_ref });
+ }
+
+ if (STEPS.includes("s3")) {
+ // Edit `default` in Settings β†’ Agents, pick qa-gamma, save.
+ await reset("default");
+ await page.goto(`${FRONT}/settings/agents`, { waitUntil: "domcontentloaded" });
+ const row = page.getByTestId("agent-profile-row").filter({ hasText: /^default/ }).first();
+ await row.waitFor({ timeout: 60_000 });
+ await row.getByTestId("agent-profile-menu-trigger").click();
+ await page.getByTestId("agent-profile-edit").click();
+ const selector = page.getByTestId("agent-profile-llm-selector");
+ await selector.waitFor({ timeout: 60_000 });
+ await page.waitForTimeout(2000);
+ const opened = {
+ nameDisabled: await page.getByTestId("agent-profile-name-input").isDisabled(),
+ llmShown: await selector.inputValue(),
+ defaultNote: await page.getByTestId("agent-profile-llm-default-note").count(),
+ };
+ await page.screenshot({ path: `${OUT}/s3-editor.png`, fullPage: true });
+ await selector.click();
+ await selector.fill("qa-gamma");
+ await page.getByRole("option", { name: /qa-gamma/ }).first().click();
+ const before = requests.length;
+ await page.getByTestId("save-agent-profile-btn").click();
+ await page.waitForTimeout(5000);
+ const writes = requests.slice(before).filter((r) => r.startsWith("POST"));
+ const saved = await agentProfile("default");
+ record("s3 edit default", {
+ opened,
+ writes,
+ saved: { llm_profile_ref: saved.llm_profile_ref, mcp_server_refs: saved.mcp_server_refs, secret_refs: saved.secret_refs },
+ orgActive: await orgActiveLlm(),
+ });
+ }
+} catch (error) {
+ record("error", { message: String(error).slice(0, 800) });
+ await page.screenshot({ path: `${OUT}/error.png` }).catch(() => undefined);
+} finally {
+ writeFileSync(`${OUT}/results.json`, JSON.stringify({ mode: MODE, dry: DRY, results, starts, blocked, requests, consoleErrors }, null, 2));
+ await browser.close();
+}
+console.log(`starts=${JSON.stringify(starts)} blocked=${blocked.length} consoleErrors=${consoleErrors.length}`);
diff --git a/.pr/cloud-default-profile/results-main.json b/.pr/cloud-default-profile/results-main.json
new file mode 100644
index 0000000000..ecc9b348eb
--- /dev/null
+++ b/.pr/cloud-default-profile/results-main.json
@@ -0,0 +1,174 @@
+{
+ "mode": "before",
+ "dry": false,
+ "results": [
+ {
+ "name": "s1 default on home",
+ "shown": {
+ "agent": "default",
+ "llm": "qa-alpha"
+ },
+ "afterPick": {
+ "agent": "default",
+ "llm": "qa-alpha"
+ },
+ "state": {
+ "defaultRef": "qa-alpha",
+ "orgActive": "qa-gamma"
+ },
+ "start": {
+ "agent_profile_id": "811c4d9d-91e6-4763-82f8-a0f97b5cc872",
+ "llm_model": null,
+ "had_message": true,
+ "response": {
+ "status": 200,
+ "id": "c0a6e75f930a4148aaf06e094b38b3ee"
+ }
+ },
+ "ran": {
+ "status": "READY",
+ "llm_model": "openai/qa-alpha-model",
+ "launched": {
+ "agent_profile_id": "811c4d9d-91e6-4763-82f8-a0f97b5cc872"
+ },
+ "conversation": "3adeafc85fc04f54a95425cb3c803bfd",
+ "note": "read via API after the run; harness recorded before the start response arrived"
+ }
+ },
+ {
+ "name": "s2 named profile on home",
+ "shown": {
+ "agent": "qa-reviewer",
+ "llm": "qa-alpha"
+ },
+ "writes": [],
+ "afterReload": {
+ "agent": "qa-reviewer",
+ "llm": "qa-alpha"
+ },
+ "reviewerRef": "qa-alpha"
+ },
+ {
+ "name": "s3 edit default",
+ "opened": {
+ "nameDisabled": true,
+ "llmShown": "qa-beta (openai/qa-beta-model)",
+ "defaultNote": 1
+ },
+ "writes": [
+ "POST /api/agent-profiles/default",
+ "POST /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles/qa-gamma/activate"
+ ],
+ "saved": {
+ "llm_profile_ref": "qa-gamma",
+ "mcp_server_refs": null,
+ "secret_refs": []
+ },
+ "orgActive": "qa-gamma"
+ }
+ ],
+ "starts": [
+ {
+ "agent_profile_id": "811c4d9d-91e6-4763-82f8-a0f97b5cc872",
+ "llm_model": null,
+ "had_message": true,
+ "response": {
+ "status": 200,
+ "id": "c0a6e75f930a4148aaf06e094b38b3ee"
+ }
+ }
+ ],
+ "blocked": [],
+ "requests": [
+ "GET /api/v1/config/models/search",
+ "GET /api/keys/current",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/v1/skills/search",
+ "GET /api/v1/web-client/config",
+ "GET /api/v1/config/models/search",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "POST /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles/qa-gamma/activate",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/v1/settings",
+ "POST /api/v1/app-conversations",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/config/models/search",
+ "GET /api/keys/current",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/v1/skills/search",
+ "GET /api/v1/web-client/config",
+ "GET /api/v1/config/models/search",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/v1/config/models/search",
+ "GET /api/keys/current",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/v1/skills/search",
+ "GET /api/v1/web-client/config",
+ "GET /api/v1/config/models/search",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/v1/config/models/search",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/agent-profiles/default",
+ "GET /api/v1/settings/agent-schema",
+ "GET /api/v1/settings/conversation-schema",
+ "GET /api/v1/secrets/search",
+ "POST /api/agent-profiles/default",
+ "GET /api/agent-profiles",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "POST /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles/qa-gamma/activate",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles"
+ ],
+ "consoleErrors": []
+}
\ No newline at end of file
diff --git a/.pr/cloud-default-profile/results-pr.json b/.pr/cloud-default-profile/results-pr.json
new file mode 100644
index 0000000000..48fde5b0fc
--- /dev/null
+++ b/.pr/cloud-default-profile/results-pr.json
@@ -0,0 +1,179 @@
+{
+ "mode": "after",
+ "dry": false,
+ "results": [
+ {
+ "name": "s1 default on home",
+ "shown": {
+ "agent": "default",
+ "llm": "qa-alpha"
+ },
+ "afterPick": {
+ "agent": "default",
+ "llm": "qa-gamma"
+ },
+ "state": {
+ "defaultRef": "qa-gamma",
+ "orgActive": "qa-beta"
+ },
+ "start": {
+ "agent_profile_id": "811c4d9d-91e6-4763-82f8-a0f97b5cc872",
+ "llm_model": null,
+ "had_message": true,
+ "response": {
+ "status": 200,
+ "id": "3d79a08883e541e3b7b28e088cdc0c69"
+ }
+ },
+ "ran": {
+ "status": "READY",
+ "detail": null,
+ "llm_model": "openai/qa-gamma-model",
+ "launched": {
+ "agent_profile_id": "811c4d9d-91e6-4763-82f8-a0f97b5cc872",
+ "revision": 8,
+ "secret_refs": null
+ },
+ "pausedSandbox": "2czD3282d29rMOju250pXd"
+ }
+ },
+ {
+ "name": "s2 named profile on home",
+ "shown": {
+ "agent": "qa-reviewer",
+ "llm": "qa-alpha"
+ },
+ "writes": [
+ "POST /api/agent-profiles/qa-reviewer"
+ ],
+ "afterReload": {
+ "agent": "qa-reviewer",
+ "llm": "qa-beta"
+ },
+ "reviewerRef": "qa-beta"
+ },
+ {
+ "name": "s3 edit default",
+ "opened": {
+ "nameDisabled": false,
+ "llmShown": "qa-alpha (openai/qa-alpha-model)",
+ "defaultNote": 0
+ },
+ "writes": [
+ "POST /api/agent-profiles/default"
+ ],
+ "saved": {
+ "llm_profile_ref": "qa-gamma",
+ "mcp_server_refs": [],
+ "secret_refs": []
+ },
+ "orgActive": "qa-beta"
+ }
+ ],
+ "starts": [
+ {
+ "agent_profile_id": "811c4d9d-91e6-4763-82f8-a0f97b5cc872",
+ "llm_model": null,
+ "had_message": true,
+ "response": {
+ "status": 200,
+ "id": "3d79a08883e541e3b7b28e088cdc0c69"
+ }
+ }
+ ],
+ "blocked": [],
+ "requests": [
+ "GET /api/v1/config/models/search",
+ "GET /api/keys/current",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/v1/skills/search",
+ "GET /api/v1/web-client/config",
+ "GET /api/v1/config/models/search",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/agent-profiles/default",
+ "POST /api/agent-profiles/default",
+ "GET /api/agent-profiles",
+ "POST /api/v1/app-conversations",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/start-tasks",
+ "GET /api/v1/app-conversations/start-tasks",
+ "GET /api/v1/app-conversations/start-tasks",
+ "GET /api/v1/app-conversations",
+ "GET /api/v1/config/models/search",
+ "GET /api/keys/current",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/v1/skills/search",
+ "GET /api/v1/web-client/config",
+ "GET /api/v1/config/models/search",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/agent-profiles/qa-reviewer",
+ "POST /api/agent-profiles/qa-reviewer",
+ "GET /api/agent-profiles",
+ "GET /api/v1/config/models/search",
+ "GET /api/keys/current",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/v1/skills/search",
+ "GET /api/v1/web-client/config",
+ "GET /api/v1/config/models/search",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/v1/config/models/search",
+ "GET /api/organizations",
+ "GET /api/keys/current",
+ "GET /api/keys/current",
+ "GET /api/v1/settings",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/profiles",
+ "GET /api/agent-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/meta-profiles",
+ "GET /api/organizations/b6f2a99b-68fa-40fa-b28b-07f38ca733e3/me",
+ "GET /api/automation/health",
+ "GET /api/automation/sdk-version",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/v1/app-conversations/search",
+ "GET /api/automation/v1",
+ "GET /api/admin/setup-state",
+ "GET /api/agent-profiles/default",
+ "GET /api/v1/settings/agent-schema",
+ "GET /api/v1/settings/conversation-schema",
+ "GET /api/v1/secrets/search",
+ "POST /api/agent-profiles/default",
+ "GET /api/agent-profiles"
+ ],
+ "consoleErrors": []
+}
\ No newline at end of file
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 f35d9f2a9b..84e10e3d0c 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
@@ -144,6 +144,14 @@ vi.mock("#/hooks/use-migrate-default-agent-profile", () => ({
ensureDefaultAgentProfileMigrated: vi.fn(),
}));
+const backendKind = vi.hoisted(() => ({ current: "local" }));
+vi.mock("#/contexts/active-backend-context", () => ({
+ useActiveBackend: () => ({
+ backend: { id: "b1", kind: backendKind.current },
+ orgId: null,
+ }),
+}));
+
function renderView() {
return render(<AgentProfilesLocalView />, {
wrapper: ({ children }) => (
@@ -183,6 +191,7 @@ describe("AgentProfilesLocalView save mapping", () => {
settingsData = {};
editTarget = "my-agent";
profileSupportsSkillsMock.mockReturnValue(true);
+ backendKind.current = "local";
});
it("opens a new profile on the settings lists when there is no OpenHands default", async () => {
@@ -718,6 +727,24 @@ describe("AgentProfilesLocalView save mapping", () => {
});
});
+ it("edits a cloud profile named default like any other profile", async () => {
+ backendKind.current = "cloud";
+ renderView();
+ const user = userEvent.setup();
+ await user.click(screen.getByTestId("edit-agent-profile"));
+ const form = await screen.findByTestId("mock-agent-settings");
+
+ expect(form).toHaveAttribute("data-default-profile", "false");
+ expect(screen.getByTestId("agent-profile-name-input")).toBeEnabled();
+ await user.click(screen.getByTestId("save-agent-profile-btn"));
+ await waitFor(() => expect(saveMutate).toHaveBeenCalledTimes(1));
+ expect(applyToGlobalMock).not.toHaveBeenCalled();
+ expect(saveMutate.mock.calls[0][0].profile).toMatchObject({
+ llm_profile_ref: "stale",
+ mcp_server_refs: ["slack"],
+ });
+ });
+
it("locks default's name, which the server would otherwise reseed", async () => {
renderView();
const user = userEvent.setup();
diff --git a/__tests__/hooks/mutation/sync-agent-profiles.test.ts b/__tests__/hooks/mutation/sync-agent-profiles.test.ts
index d2ca18d927..38d1987984 100644
--- a/__tests__/hooks/mutation/sync-agent-profiles.test.ts
+++ b/__tests__/hooks/mutation/sync-agent-profiles.test.ts
@@ -15,6 +15,7 @@ import {
mcpServerRenamed,
routerDetached,
withSkillSelection,
+ updateAgentProfile,
updateDefaultAgentProfile,
updateEveryAgentProfile,
} from "#/hooks/mutation/sync-agent-profiles";
@@ -221,6 +222,23 @@ describe("profile writes", () => {
expect(displayErrorToast).not.toHaveBeenCalled();
});
+ it("saves one profile's change on Cloud, without the local migration", async () => {
+ useBackend("cloud");
+ storeProfiles(openHands("reviewer"));
+
+ await updateAgentProfile(
+ queryClient,
+ "reviewer",
+ llmProfileMirrored("fast"),
+ );
+
+ expect(settleRunningDefaultAgentProfileMigration).not.toHaveBeenCalled();
+ expect(AgentProfilesService.saveProfile).toHaveBeenCalledWith(
+ "reviewer",
+ expect.objectContaining({ llm_profile_ref: "fast" }),
+ );
+ });
+
it("runs writes one at a time, so the second reads the first's save", async () => {
let stored = openHands("default", { mcp_server_refs: ["a", "b", "c"] });
vi.mocked(AgentProfilesService.getProfile).mockImplementation(
diff --git a/__tests__/hooks/use-chat-input-llm-profile-state.test.tsx b/__tests__/hooks/use-chat-input-llm-profile-state.test.tsx
index 5ec6e461b8..654df17a00 100644
--- a/__tests__/hooks/use-chat-input-llm-profile-state.test.tsx
+++ b/__tests__/hooks/use-chat-input-llm-profile-state.test.tsx
@@ -44,8 +44,11 @@ const useAgentProfilesMock = vi.fn();
vi.mock("#/hooks/query/use-agent-profiles", () => ({
useAgentProfiles: () => useAgentProfilesMock(),
}));
+const backendKind = vi.hoisted(() => ({ current: "local" }));
vi.mock("#/contexts/active-backend-context", () => ({
- useActiveBackend: () => ({ backend: { id: "b1", kind: "local" } }),
+ useActiveBackend: () => ({
+ backend: { id: "b1", kind: backendKind.current },
+ }),
}));
const updateAgentProfileMock = vi.hoisted(() => vi.fn());
vi.mock("#/hooks/mutation/sync-agent-profiles", async (importOriginal) => ({
@@ -92,6 +95,7 @@ describe("useChatInputLlmProfileState", () => {
useCanManageOrgProfilesMock.mockReturnValue(true);
useAgentProfilesMock.mockReturnValue({ data: undefined });
updateAgentProfileMock.mockReset();
+ backendKind.current = "local";
});
const activeAgent = (name: string, llmProfileRef: string) =>
@@ -144,6 +148,19 @@ describe("useChatInputLlmProfileState", () => {
expect(switchAndLog).toHaveBeenCalledWith(null, "Smart");
});
+ it("treats a cloud profile named default like any other profile", () => {
+ backendKind.current = "cloud";
+ useOptionalConversationIdMock.mockReturnValue({ conversationId: null });
+ activeAgent("default", "Smart");
+
+ const { result } = renderState();
+ expect(result.current.currentProfileName).toBe("Smart");
+ result.current.selectProfile("Fast");
+
+ expect(switchAndLog).not.toHaveBeenCalled();
+ expect(updateAgentProfileMock.mock.calls[0][1]).toBe("default");
+ });
+
it("prefers the profile stamped on the conversation over a model match", () => {
useActiveConversationMock.mockReturnValue({
data: { active_profile: "Smart", llm_model: "gpt-4o-mini" },
@@ -228,6 +245,19 @@ describe("useChatInputLlmProfileState", () => {
expect(switchAndLog).not.toHaveBeenCalled();
});
+ it("holds a member's home pick instead of editing the org's agent profile", () => {
+ backendKind.current = "cloud";
+ useOptionalConversationIdMock.mockReturnValue({ conversationId: null });
+ useCanManageOrgProfilesMock.mockReturnValue(false);
+ activeAgent("reviewer", "Fast");
+
+ const { result } = renderState();
+ result.current.selectProfile("Smart");
+
+ expect(setHomeLlmProfile).toHaveBeenCalledWith("Smart");
+ expect(updateAgentProfileMock).not.toHaveBeenCalled();
+ });
+
it.each([
{
description: "names a member's home pick on the home page",
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 763bf84c69..6dbfffd36f 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
@@ -131,6 +131,13 @@ export function AgentProfilesLocalView() {
: Promise.resolve(true as const),
[backend.kind, backend.id, queryClient],
);
+ // On cloud, `default` is an ordinary profile name.
+ const isSharedDefault = useCallback(
+ (name: string | undefined) =>
+ backend.kind === "local" &&
+ name === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME,
+ [backend.kind],
+ );
const [viewMode, setViewMode] = useState<ViewMode>("list");
const [profileName, setProfileName] = useState("");
@@ -217,8 +224,7 @@ export function AgentProfilesLocalView() {
"encrypted",
);
const profile = detail.profile;
- const isDefault =
- profile.name === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME;
+ const isDefault = isSharedDefault(profile.name);
setEditingProfile(profile);
setOverride(
isDefault && profile.agent_kind === "openhands"
@@ -263,6 +269,7 @@ export function AgentProfilesLocalView() {
isLlmProfilesLoading,
defaultLlmProfileRef,
waitForMigration,
+ isSharedDefault,
settings,
],
);
@@ -310,7 +317,7 @@ export function AgentProfilesLocalView() {
viewMode === "edit" && originalName && originalName !== trimmedName;
const savesDefault =
viewMode === "edit" &&
- originalName === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME &&
+ isSharedDefault(originalName) &&
trimmedName === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME &&
input.agent_kind === "openhands";
@@ -369,6 +376,7 @@ export function AgentProfilesLocalView() {
t,
handleBackToList,
waitForMigration,
+ isSharedDefault,
queryClient,
]);
@@ -393,11 +401,9 @@ export function AgentProfilesLocalView() {
: t(I18nKey.SETTINGS$AGENT_PROFILE_SAVE_HINT);
const isOpenHands = saveControl?.agentType !== "acp";
const isDefaultLocked =
- viewMode === "edit" &&
- editingProfile?.name === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME;
+ viewMode === "edit" && isSharedDefault(editingProfile?.name);
const isEditingDefault =
- viewMode === "edit" &&
- editingProfile?.name === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME &&
+ isDefaultLocked &&
profileName.trim() === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME;
const nameDirty = viewMode === "edit" && profileName !== editingProfile?.name;
const loadedLlmRef =
diff --git a/src/hooks/mutation/sync-agent-profiles.ts b/src/hooks/mutation/sync-agent-profiles.ts
index f360155dc3..41522c430c 100644
--- a/src/hooks/mutation/sync-agent-profiles.ts
+++ b/src/hooks/mutation/sync-agent-profiles.ts
@@ -71,7 +71,7 @@ interface WriteOptions {
throwOnError?: boolean;
}
-/** Run profile writes one at a time on a local backend, so each reads the previous one's result. */
+/** Run profile writes one at a time, so each reads the previous one's result. */
function enqueue(
queryClient: QueryClient,
write: () => Promise<boolean>,
@@ -79,11 +79,13 @@ function enqueue(
): Promise<void> {
const run = queue.then(async () => {
const { backend } = getActiveBackend();
- if (backend.kind !== "local" || isNoBackend(backend)) return;
- await settleRunningDefaultAgentProfileMigration(
- queryClient,
- backend.id,
- ).catch(() => undefined);
+ if (isNoBackend(backend)) return;
+ if (backend.kind === "local") {
+ await settleRunningDefaultAgentProfileMigration(
+ queryClient,
+ backend.id,
+ ).catch(() => undefined);
+ }
if (await write()) {
await queryClient.invalidateQueries({
queryKey: AGENT_PROFILES_QUERY_KEYS.all,
@@ -100,7 +102,11 @@ function enqueue(
});
}
-/** Change one local profile. */
+const onLocalBackend =
+ (write: () => Promise<boolean>) => async (): Promise<boolean> =>
+ getActiveBackend().backend.kind === "local" && write();
+
+/** Change one profile. */
export function updateAgentProfile(
queryClient: QueryClient,
name: string,
@@ -122,12 +128,13 @@ export function updateDefaultAgentProfile(
): Promise<void> {
return enqueue(
queryClient,
- async () =>
+ onLocalBackend(async () =>
saveChange(
WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME,
await readProfile(WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME),
change,
),
+ ),
options,
);
}
@@ -140,7 +147,7 @@ export function updateEveryAgentProfile(
): Promise<void> {
return enqueue(
queryClient,
- async () => {
+ onLocalBackend(async () => {
const { profiles } = await AgentProfilesService.listProfiles();
const saved = await Promise.all(
profiles.map(async ({ name }) =>
@@ -148,7 +155,7 @@ export function updateEveryAgentProfile(
),
);
return saved.some(Boolean);
- },
+ }),
options,
);
}
diff --git a/src/hooks/use-chat-input-llm-profile-state.ts b/src/hooks/use-chat-input-llm-profile-state.ts
index 861419a614..2bc6c94362 100644
--- a/src/hooks/use-chat-input-llm-profile-state.ts
+++ b/src/hooks/use-chat-input-llm-profile-state.ts
@@ -32,9 +32,9 @@ export interface ChatInputLlmProfileState {
canSwitchProfile: boolean;
/**
* Switch the LLM profile: live via `/switch_profile` inside a conversation.
- * On the home page it becomes the active agent profile's LLM, which for
- * `default` means activating it (see {@link useSwitchLlmProfile}). A cloud
- * member's home pick is held for the next home launch instead.
+ * On the home page it becomes the active agent profile's LLM, which for a
+ * local `default` means activating it (see {@link useSwitchLlmProfile}). A
+ * cloud member's home pick is held for the next home launch instead.
*/
selectProfile: (profileName: string) => void;
}
@@ -53,7 +53,7 @@ export function useChatInputLlmProfileState(): ChatInputLlmProfileState {
const queryClient = useQueryClient();
const { backend } = useActiveBackend();
const { data: agentProfiles } = useAgentProfiles({
- enabled: !conversationId && backend.kind === "local",
+ enabled: !conversationId,
});
const canManageOrgProfiles = useCanManageOrgProfiles();
const { switchAndLog } = useSwitchLlmProfileAndLog();
@@ -108,12 +108,15 @@ export function useChatInputLlmProfileState(): ChatInputLlmProfileState {
profiles.some((p) => p.name === activeAgentProfile.llm_profile_ref)
? activeAgentProfile.llm_profile_ref
: null;
- // `default` runs the active LLM profile, so a home pick activates it; any
- // other profile keeps the pick as its own LLM.
+ // A local `default` runs the active LLM profile, so a home pick activates
+ // it; any other profile keeps the pick as its own LLM.
const ownsHomeLlm =
!conversationId &&
agentLlmProfile !== null &&
- activeAgentProfile?.name !== WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME;
+ !(
+ backend.kind === "local" &&
+ activeAgentProfile?.name === WELL_KNOWN_DEFAULT_AGENT_PROFILE_NAME
+ );
const currentProfileName =
optimisticActiveProfile ??
conversationProfile ??
@@ -132,17 +135,9 @@ export function useChatInputLlmProfileState(): ChatInputLlmProfileState {
const selectProfile = useCallback(
(profileName: string) => {
if (!canSwitchProfile || profileName === currentProfileName) return;
- if (ownsHomeLlm && activeAgentProfile) {
- updateAgentProfile(
- queryClient,
- activeAgentProfile.name,
- llmProfileMirrored(profileName),
- );
- return;
- }
if (!conversationId) {
- // Otherwise a home pick activates the profile account-wide β€” on cloud
- // that's the org-gated activate endpoint a member can only 403 on.
+ // A home pick edits the org's agent profile or activates the LLM
+ // profile org-wide, both of which a cloud member can only 403 on.
// Hold a member's pick for the next home launch (sent as
// `llm_profile`).
if (!canManageOrgProfiles) {
@@ -150,6 +145,14 @@ export function useChatInputLlmProfileState(): ChatInputLlmProfileState {
return;
}
setHomeLlmProfile(null);
+ if (ownsHomeLlm && activeAgentProfile) {
+ updateAgentProfile(
+ queryClient,
+ activeAgentProfile.name,
+ llmProfileMirrored(profileName),
+ );
+ return;
+ }
}
switchAndLog(conversationId, profileName);
},