Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: preserve base_url for subscription LLM configs (#16089)

Graham Neubig2ead26e77271
diff --git a/__tests__/api/agent-server-adapter.test.ts b/__tests__/api/agent-server-adapter.test.ts
index 331ca13ab0..b9d31f1751 100644
--- a/__tests__/api/agent-server-adapter.test.ts
+++ b/__tests__/api/agent-server-adapter.test.ts
@@ -261,7 +261,7 @@ describe("buildStartConversationRequest", () => {
expect(payload.initial_message.content[0]?.text).toBe("hello");
});
- it("uses subscription auth metadata without API credentials", () => {
+ it("preserves base_url for subscription auth while stripping api_key", () => {
const payload = buildStartConversationRequest({
settings: {
...DEFAULT_SETTINGS,
@@ -270,7 +270,7 @@ describe("buildStartConversationRequest", () => {
llm: {
model: "gpt-5.2-codex",
api_key: "stale-api-key",
- base_url: "https://api.openai.com/v1",
+ base_url: "https://chatgpt.com/backend-api/codex",
auth_type: LLM_AUTH_TYPE_SUBSCRIPTION,
subscription_vendor: OPENAI_SUBSCRIPTION_VENDOR,
},
@@ -281,6 +281,7 @@ describe("buildStartConversationRequest", () => {
expect(payload.agent_settings.llm).toEqual({
model: "gpt-5.2-codex",
stream: true,
+ base_url: "https://chatgpt.com/backend-api/codex",
auth_type: LLM_AUTH_TYPE_SUBSCRIPTION,
subscription_vendor: OPENAI_SUBSCRIPTION_VENDOR,
});
diff --git a/src/api/agent-server-adapter.ts b/src/api/agent-server-adapter.ts
index 3497bcf72d..54558aa52e 100644
--- a/src/api/agent-server-adapter.ts
+++ b/src/api/agent-server-adapter.ts
@@ -632,7 +632,6 @@ function buildNormalizedLlmSettings(value: unknown): SettingsRecord {
llm.auth_type = LLM_AUTH_TYPE_SUBSCRIPTION;
llm.subscription_vendor = OPENAI_SUBSCRIPTION_VENDOR;
delete llm.api_key;
- delete llm.base_url;
} else {
delete llm.auth_type;
delete llm.subscription_vendor;
diff --git a/tests/e2e/mock-llm/utils/mock-llm-helpers.ts b/tests/e2e/mock-llm/utils/mock-llm-helpers.ts
index 6043178e32..991dd158f6 100644
--- a/tests/e2e/mock-llm/utils/mock-llm-helpers.ts
+++ b/tests/e2e/mock-llm/utils/mock-llm-helpers.ts
@@ -704,8 +704,13 @@ export async function deleteProfileIfExists(page: Page, profileName: string) {
const confirmBtn = page.getByTestId("delete-profile-confirm");
await confirmBtn.waitFor({ state: "visible", timeout: 5_000 });
await confirmBtn.click();
+ // The profile list remains visible behind the modal, so merely waiting for
+ // `add-llm-profile` does not prove the delete mutation has finished. Wait
+ // for both the modal and the exact row to disappear before a caller tries
+ // to delete or create another profile.
await expect(confirmBtn).toBeHidden({ timeout: 30_000 });
- await expect(row).toBeHidden({ timeout: 30_000 });
+ await expect(row).toHaveCount(0, { timeout: 30_000 });
+ await waitForTestId(page, "add-llm-profile");
} else {
await page.keyboard.press("Escape");
}