🙌 OpenHands: AI-Driven Development
fix(settings): preserve the new LLM profile form values (#18422)
Engel Nystbf483c12efbf
diff --git a/.agents/skills/verify-openhands/references/feature-map/F10-llm-profiles.md b/.agents/skills/verify-openhands/references/feature-map/F10-llm-profiles.mdindex 5e9a65d3a1..a756799372 100644--- a/.agents/skills/verify-openhands/references/feature-map/F10-llm-profiles.md+++ b/.agents/skills/verify-openhands/references/feature-map/F10-llm-profiles.md@@ -121,3 +121,58 @@ Preconditions:- Toasts last only a few seconds. A `browser screenshot` taken after a slow command can miss them, so assert with `browser wait-text` or `browser toasts`.- Known issue #17955: a new profile is saved without the inherited LLM options the editor shows, such as temperature (`F10.create-prefill`).- `Subscription models are not loaded yet.` is translated in every language (`SETTINGS$SUBSCRIPTION_MODELS_NOT_LOADED`, #18308; source check 2026-10-13, not driven live). It shows when a subscription profile is saved before `GET /api/llm/subscription/openai/models` answers, in the settings save (`src/routes/llm-settings.tsx`) and in onboarding's LLM step. No recipe drives it, since it needs that request to be slow or to fail.++ ```sh known-bug F10.create-prefill desktop-inherited+ control-openhands llm set --profile QA_Inherit --model deepseek/deepseek-flash --api-key-env DEEPSEEK_API_KEY --no-activate --no-validate+ control-openhands api DELETE /api/profiles/QA_Inherit --write+ control-openhands api PATCH /api/settings --write --data '{"agent_settings_diff":{"llm":{"temperature":0.4}}}'+ control-openhands browser viewport desktop+ control-openhands browser goto /settings/llm+ control-openhands browser click 'testid=add-llm-profile'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands assert --field value --equals 0.4 -- browser value 'testid=sdk-settings-llm.temperature'+ control-openhands browser fill 'testid=llm-custom-model-input' deepseek/deepseek-flash+ control-openhands browser fill 'testid=profile-name-input' QA_Inherit+ control-openhands browser fill 'testid=llm-api-key-input' --value-env DEEPSEEK_API_KEY+ control-openhands browser record start --feature F10.create-prefill --name inherited-save+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name inherited-before-save+ control-openhands browser click 'testid=save-profile-btn'+ control-openhands browser wait-text 'created'+ control-openhands browser click '[data-testid=profile-row]:has([title="QA_Inherit"]) >> testid=profile-menu-trigger'+ control-openhands browser click 'testid=profile-actions-menu >> testid=profile-edit'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name inherited-after-save+ control-openhands browser record stop --gif+ control-openhands api GET /api/profiles/QA_Inherit --pick config.temperature+ control-openhands assert --field value --equals 0.4 --bug-shows '' -- browser value 'testid=sdk-settings-llm.temperature' # bug+ ```++ ```sh known-bug F10.create-prefill phone-inherited+ control-openhands llm set --profile QA_Inherit --model deepseek/deepseek-flash --api-key-env DEEPSEEK_API_KEY --no-activate --no-validate+ control-openhands api DELETE /api/profiles/QA_Inherit --write+ control-openhands api PATCH /api/settings --write --data '{"agent_settings_diff":{"llm":{"temperature":0.4}}}'+ control-openhands browser viewport phone+ control-openhands browser goto /settings/llm+ control-openhands browser click 'testid=add-llm-profile'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands assert --field value --equals 0.4 -- browser value 'testid=sdk-settings-llm.temperature'+ control-openhands browser fill 'testid=llm-custom-model-input' deepseek/deepseek-flash+ control-openhands browser fill 'testid=profile-name-input' QA_Inherit+ control-openhands browser fill 'testid=llm-api-key-input' --value-env DEEPSEEK_API_KEY+ control-openhands browser record start --feature F10.create-prefill --name phone-inherited-save+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name phone-inherited-before-save+ control-openhands browser click 'testid=save-profile-btn'+ control-openhands browser wait-text 'created'+ control-openhands browser click '[data-testid=profile-row]:has([title="QA_Inherit"]) >> testid=profile-menu-trigger'+ control-openhands browser click 'testid=profile-actions-menu >> testid=profile-edit'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name phone-inherited-after-save+ control-openhands browser record stop --gif+ control-openhands api GET /api/profiles/QA_Inherit --pick config.temperature+ control-openhands assert --field value --equals 0.4 --bug-shows '' -- browser value 'testid=sdk-settings-llm.temperature' # bug+ ```+diff --git a/.pr/17955/EVIDENCE.md b/.pr/17955/EVIDENCE.mdnew file mode 100644index 0000000000..5968c77d17--- /dev/null+++ b/.pr/17955/EVIDENCE.md@@ -0,0 +1,22 @@+# Retained verification evidence++This evidence comes from the stopped `settings-17955-after-20261013` run at+fix revision `13da51daff35ae685f8fe13d3723b69c8464ab76`.++It covers only `F10.create-prefill`: the displayed inherited temperature `0.4`+survives creation and reopening of a new LLM profile, on desktop and phone,+two attempts each. The four attempts are recorded as **xpass**; each report+contains the asserted value before and after saving. These are fix-side results,+not a complete baseline/fix proof or verification of every profile option.++`evidence/` retains 22 files: eight screenshots, eight MP4/GIF recordings,+four assertion reports and two ledgers. Some captures repeat the same state;+the count is files, not independent checks. Raw stdout/stderr, embedded recipe+scripts and machine-local paths were removed from committed reports; original+private transcripts remain outside Git. Media received credential-pattern OCR+screening across the stills and sampled recording frames. No private runtime+state, credentials or traces are committed.++The feature-map update adds the reproducible desktop/phone known-bug recipes.+The design page describes the source proposal and does not substitute for live+proof. Issue #17955 remains open; this local fix has not been merged upstream.diff --git a/.pr/17955/bug-recipes.md b/.pr/17955/bug-recipes.mdnew file mode 100644index 0000000000..f77326af91--- /dev/null+++ b/.pr/17955/bug-recipes.md@@ -0,0 +1,59 @@+# Frozen baseline/fix recipes++I am an AI agent helping Engel Nyst (@enyst) with project maintenance.++These scripts preserve the exact recipe used for comparison. Run them only against an isolated control-openhands run with the appropriate backend pins and test credential environment. The maintained feature map converts the accepted behavior to a normal recipe after verification.++ ```sh known-bug F10.create-prefill desktop-inherited+ control-openhands llm set --profile QA_Inherit --model deepseek/deepseek-flash --api-key-env DEEPSEEK_API_KEY --no-activate --no-validate+ control-openhands api DELETE /api/profiles/QA_Inherit --write+ control-openhands api PATCH /api/settings --write --data '{"agent_settings_diff":{"llm":{"temperature":0.4}}}'+ control-openhands browser viewport desktop+ control-openhands browser goto /settings/llm+ control-openhands browser click 'testid=add-llm-profile'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands assert --field value --equals 0.4 -- browser value 'testid=sdk-settings-llm.temperature'+ control-openhands browser fill 'testid=llm-custom-model-input' deepseek/deepseek-flash+ control-openhands browser fill 'testid=profile-name-input' QA_Inherit+ control-openhands browser fill 'testid=llm-api-key-input' --value-env DEEPSEEK_API_KEY+ control-openhands browser record start --feature F10.create-prefill --name inherited-save+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name inherited-before-save+ control-openhands browser click 'testid=save-profile-btn'+ control-openhands browser wait-text 'created'+ control-openhands browser click '[data-testid=profile-row]:has([title="QA_Inherit"]) >> testid=profile-menu-trigger'+ control-openhands browser click 'testid=profile-actions-menu >> testid=profile-edit'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name inherited-after-save+ control-openhands browser record stop --gif+ control-openhands api GET /api/profiles/QA_Inherit --pick config.temperature+ control-openhands assert --field value --equals 0.4 --bug-shows '' -- browser value 'testid=sdk-settings-llm.temperature' # bug+ ```++ ```sh known-bug F10.create-prefill phone-inherited+ control-openhands llm set --profile QA_Inherit --model deepseek/deepseek-flash --api-key-env DEEPSEEK_API_KEY --no-activate --no-validate+ control-openhands api DELETE /api/profiles/QA_Inherit --write+ control-openhands api PATCH /api/settings --write --data '{"agent_settings_diff":{"llm":{"temperature":0.4}}}'+ control-openhands browser viewport phone+ control-openhands browser goto /settings/llm+ control-openhands browser click 'testid=add-llm-profile'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands assert --field value --equals 0.4 -- browser value 'testid=sdk-settings-llm.temperature'+ control-openhands browser fill 'testid=llm-custom-model-input' deepseek/deepseek-flash+ control-openhands browser fill 'testid=profile-name-input' QA_Inherit+ control-openhands browser fill 'testid=llm-api-key-input' --value-env DEEPSEEK_API_KEY+ control-openhands browser record start --feature F10.create-prefill --name phone-inherited-save+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name phone-inherited-before-save+ control-openhands browser click 'testid=save-profile-btn'+ control-openhands browser wait-text 'created'+ control-openhands browser click '[data-testid=profile-row]:has([title="QA_Inherit"]) >> testid=profile-menu-trigger'+ control-openhands browser click 'testid=profile-actions-menu >> testid=profile-edit'+ control-openhands browser click 'testid=sdk-section-all-toggle'+ control-openhands browser scroll 'testid=sdk-settings-llm.temperature'+ control-openhands browser screenshot --feature F10.create-prefill --name phone-inherited-after-save+ control-openhands browser record stop --gif+ control-openhands api GET /api/profiles/QA_Inherit --pick config.temperature+ control-openhands assert --field value --equals 0.4 --bug-shows '' -- browser value 'testid=sdk-settings-llm.temperature' # bug+ ```diff --git a/.pr/17955/design.html b/.pr/17955/design.htmlnew file mode 100644index 0000000000..bc033c4db1--- /dev/null+++ b/.pr/17955/design.html@@ -0,0 +1,183 @@+<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Preserve the new profile’s displayed options</title><style> :root{--fg:#1a1a1a;--muted:#5a5a5a;--subtle:#8a8a82;--bg:#fdfdfb;--card:#fff;--elevated:#f7f6f1;--accent:#2b4eaa;--accent-soft:#e6ecfa;--rule:#e2e2dc;--code-bg:#f3f1ec;--warn:#b25b0e;--mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.6 var(--sans)}.wrap{display:grid;grid-template-columns:200px minmax(0,1fr);gap:40px;max-width:1220px;margin:auto;padding:36px 28px 90px}nav{position:sticky;top:24px;align-self:start;font-size:13px}nav a{display:block;margin:12px 0;overflow-wrap:anywhere}a{color:var(--accent)}header{border-bottom:1px solid var(--rule);padding-bottom:24px}h1{font-size:34px;line-height:1.2;margin:8px 0 16px}h2{margin:36px 0 12px;font-size:23px}h3{font-size:17px}.eyebrow{font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--accent)}.sub{color:var(--muted)}.callout{background:var(--accent-soft);border-left:3px solid var(--accent);padding:12px 16px;margin:18px 0}.ba{display:grid;grid-template-columns:1fr 1fr;gap:16px}figure{margin:0}svg{display:block;width:100%;height:auto;background:var(--card);border:1px solid var(--rule);border-radius:6px}figcaption{font-size:13px;color:var(--muted);margin:8px 0 16px}code,pre{font-family:var(--mono);background:var(--code-bg);font-size:13px}code{padding:2px 4px}pre{overflow:auto;padding:16px}.src{font-family:var(--mono);font-size:11px;overflow-wrap:anywhere}details{border:1px solid var(--rule);margin:12px 0;border-radius:6px}summary{padding:10px 14px;cursor:pointer;font-size:13px}table{border-collapse:collapse;width:100%;font-size:14px}th,td{padding:10px;border-bottom:1px solid var(--rule);text-align:left;vertical-align:top}th{background:var(--elevated)}footer{margin-top:44px;color:var(--muted);font-size:12px}@media(max-width:850px){.wrap{grid-template-columns:1fr;gap:12px}nav{position:static}.ba{grid-template-columns:1fr}h1{font-size:28px}}</style></head><body><div class="wrap"><nav><strong>Review index</strong><a href="#flow">1. Persistence flow</a><a href="#rules">2. Behavioral boundaries</a><a href="#tests">3. Contract and tests</a><a href="#diff">4. Focused source diff</a><details><summary>Changed files</summary><p>215 0 __tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx</p><p>1 0 __tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx</p><p>15 0 specs/llm-profiles.md</p><p>86 15 src/components/features/settings/llm-profiles/llm-settings-local-view.tsx</p></details></nav><main><header><div class="eyebrow">OpenHands · proposal #17955 · 2026-10-13</div><h1>Preserve the new profile’s displayed options</h1><p class="sub">Creating a profile now saves the non-secret options already shown in its form, using the same schema coercion as explicit edits. Automatic booleans retain their raw meaning; credentials start blank and enter the payload only through explicit edits.</p><p class="callout">★ Untouched Temperature 0.4 must survive Save and reopen; an unchecked automatic boolean must remain automatic.</p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L114">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:114</a></header><section id="flow"><h2>The persistence flow changes before the write</h2><p>The API endpoint and profile configuration shape remain unchanged. This proposal changes which configuration values or name enter the existing save call. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L346">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:346</a></p><div class="ba"><figure><h3>Before</h3><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 410 380" role="img" aria-labelledby="before-t before-d"><title id="before-t">Before</title><desc id="before-d">saveControl.getDirtyPayload() → buildProfileLlmConfig() → saveProfile.mutateAsync()</desc><defs><marker id="before-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0,0 L10,5 L0,10 Z" fill="var(--subtle)"/></marker><linearGradient id="before-wash" x2="0" y2="1"><stop stop-color="var(--accent)" stop-opacity=".10"/><stop offset="1" stop-color="var(--accent)" stop-opacity=".02"/></linearGradient></defs><style>.existing{fill:var(--code-bg);stroke:var(--subtle);stroke-dasharray:5 3;stroke-width:1.4}.new{fill:var(--accent-soft);stroke:var(--accent);stroke-width:2}.title{font:700 14px var(--sans);fill:var(--fg)}.detail{font:12px var(--sans);fill:var(--muted)}.loc{font:11px var(--mono);fill:var(--accent)}.edge{stroke:var(--subtle);stroke-width:1.8;stroke-dasharray:5 3;fill:none}</style><!-- saveControl.getDirtyPayload() --><g><rect class="existing" x="16" y="24" width="378" height="92" rx="6"/><text class="title" x="32" y="52">saveControl.getDirtyPayload()</text><text class="detail" x="32" y="75">Untouched displayed options are absent</text><a href="https://github.com/OpenHands/OpenHands/blob/bdb69754a113e3458d3645dfba0676ae73f4ebc3/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L256"><text class="loc" x="32" y="99">llm-settings-local-view.tsx:256</text></a></g><path class="edge" d="M205,118 L205,139" marker-end="url(#before-arrow)"/><!-- buildProfileLlmConfig() --><g><rect class="existing" x="16" y="142" width="378" height="92" rx="6"/><text class="title" x="32" y="170">buildProfileLlmConfig()</text><text class="detail" x="32" y="193">Create mode has no saved base config</text><a href="https://github.com/OpenHands/OpenHands/blob/bdb69754a113e3458d3645dfba0676ae73f4ebc3/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L267"><text class="loc" x="32" y="217">llm-settings-local-view.tsx:267</text></a></g><path class="edge" d="M205,236 L205,257" marker-end="url(#before-arrow)"/><!-- saveProfile.mutateAsync() --><g><rect class="existing" x="16" y="260" width="378" height="92" rx="6"/><text class="title" x="32" y="288">saveProfile.mutateAsync()</text><text class="detail" x="32" y="311">Missing options fall back to backend defaults</text><a href="https://github.com/OpenHands/OpenHands/blob/bdb69754a113e3458d3645dfba0676ae73f4ebc3/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L321"><text class="loc" x="32" y="335">llm-settings-local-view.tsx:321</text></a></g></svg><figcaption>Only dirty fields entered a new profile’s configuration; untouched temperature disappeared.</figcaption></figure><figure><h3>After</h3><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 410 380" role="img" aria-labelledby="after-t after-d"><title id="after-t">After</title><desc id="after-d">buildSdkSettingsPayload() → getDirtyPayload() + initialPayload → buildProfileLlmConfig()</desc><defs><marker id="after-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0,0 L10,5 L0,10 Z" fill="var(--warn)"/></marker><linearGradient id="after-wash" x2="0" y2="1"><stop stop-color="var(--accent)" stop-opacity=".10"/><stop offset="1" stop-color="var(--accent)" stop-opacity=".02"/></linearGradient></defs><style>.existing{fill:var(--code-bg);stroke:var(--subtle);stroke-dasharray:5 3;stroke-width:1.4}.new{fill:var(--accent-soft);stroke:var(--accent);stroke-width:2}.title{font:700 14px var(--sans);fill:var(--fg)}.detail{font:12px var(--sans);fill:var(--muted)}.loc{font:11px var(--mono);fill:var(--accent)}.edge{stroke:var(--warn);stroke-width:1.8;stroke-dasharray:5 3;fill:none}</style><!-- buildSdkSettingsPayload() --><g><rect class="new" style="fill:url(#after-wash)" x="16" y="24" width="378" height="92" rx="6"/><text class="title" x="32" y="52">buildSdkSettingsPayload()</text><text class="detail" x="32" y="75">Coerce non-secret, non-automatic draft values</text><a href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L316"><text class="loc" x="32" y="99">llm-settings-local-view.tsx:316</text></a></g><path class="edge" d="M205,118 L205,139" marker-end="url(#after-arrow)"/><!-- getDirtyPayload() + initialPayload --><g><rect class="new" x="16" y="142" width="378" height="92" rx="6"/><text class="title" x="32" y="170">getDirtyPayload() + initialPayload</text><text class="detail" x="32" y="193">Explicit edits override preserved options</text><a href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L332"><text class="loc" x="32" y="217">llm-settings-local-view.tsx:332</text></a></g><path class="edge" d="M205,236 L205,257" marker-end="url(#after-arrow)"/><!-- buildProfileLlmConfig() --><g><rect class="new" x="16" y="260" width="378" height="92" rx="6"/><text class="title" x="32" y="288">buildProfileLlmConfig()</text><text class="detail" x="32" y="311">Existing auth normalization still owns credentials</text><a href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L346"><text class="loc" x="32" y="335">llm-settings-local-view.tsx:346</text></a></g></svg><figcaption>The create payload adds semantic draft values before the existing auth normalization.</figcaption></figure></div></section><section id="rules"><h2>The changed path preserves existing meaning</h2><details><summary>Source manifest</summary><p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L1">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:1</a></p><p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/utils/sdk-settings-schema.ts#L108">src/utils/sdk-settings-schema.ts:108</a></p><p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-profile-form.ts#L92">src/components/features/settings/llm-profiles/llm-profile-form.ts:92</a></p></details><h3>Blank every schema secret</h3><p>createProfileInitialValues initializes all secret fields to an empty string. The default model, Base URL, provider connection and authentication defaults remain explicit. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L114">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:114</a></p><h3>Preserve automatic booleans</h3><p>handleSaveControlChange captures null-default booleans from the raw draft origin once. getAgentSettingValue normalizes an omitted value to null. Later query refreshes cannot change this open draft’s origin. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L250">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:250</a></p><h3>Merge explicit edits last</h3><p>handleSave uses the existing schema serializer for initial options and overlays the real dirty payload. Existing edit mode continues to merge over the saved profile config. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L301">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:301</a></p><p>Unchanged serializer: <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/utils/sdk-settings-schema.ts#L108">src/utils/sdk-settings-schema.ts:108</a></p><p>Unchanged auth boundary: <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-profile-form.ts#L92">src/components/features/settings/llm-profiles/llm-profile-form.ts:92</a></p></section><section id="tests"><h2>The contract is exercised through the form</h2><p>The real embedded form verifies Temperature 0.4, blank inherited credentials, null and omitted automatic booleans, explicit false, dirty true, and false retained through a real settings-query refresh. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx#L92">__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx:92</a></p><p>Stable contract: <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/specs/llm-profiles.md#L3">specs/llm-profiles.md:3</a> <code>LLP-001</code>.</p><p>Live baseline/fix evidence is retained separately in the PR verification report. This design page describes source behavior; it does not substitute for runtime proof.</p></section><section id="diff"><h2>The source delta stays focused</h2><details><summary>Changed persistence logic</summary><pre>diff --git a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx+index 1b3e12f6c4..01b5c571e9 100644+--- a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx++++ b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx+@@ -47,7 +47,11 @@ import {+ LLM_SUBSCRIPTION_VENDOR_KEY,+ OPENAI_SUBSCRIPTION_VENDOR,+ } from "#/constants/llm-subscription";+-import { SettingsFormValues } from "#/utils/sdk-settings-schema";++import {++ buildSdkSettingsPayload,++ getAgentSettingValue,++ SettingsFormValues,++} from "#/utils/sdk-settings-schema";+ import { BackNavButton } from "#/components/shared/buttons/back-nav-button";+ import { Typography } from "#/ui/typography";+ import { useSettingsSectionHeader } from "#/contexts/settings-section-header-context";+@@ -109,6 +113,26 @@ export function LlmSettingsLocalView() {+ // embedded form hydrates, so the eventual DB default never replaces it and+ // the user can save the wrong model.+ const isDefaultModelReady = useDefaultModelReady();++ // @spec LLP-001 — A fresh profile never inherits schema-declared credentials.++ const createProfileInitialValues = useMemo(++ () => ({++ // A fresh profile may inherit options, but no existing credentials.++ ...Object.fromEntries(++ (agentSchema?.sections ?? []).flatMap((section) =>++ section.fields++ .filter((field) => field.secret)++ .map((field) => [field.key, ""]),++ ),++ ),++ "llm.model": createProfileDefaultModel,++ "llm.api_key": "",++ "llm.base_url": "",++ [LLM_PROVIDER_CONNECTION_KEY]: "",++ [LLM_AUTH_TYPE_KEY]: LLM_AUTH_TYPE_API_KEY,++ [LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,++ }),++ [agentSchema, createProfileDefaultModel],++ );++ // Always hold the freshest schema. `handleEditProfile` awaits a network+ // round-trip before seeding the form, so reading the schema from a ref+@@ -118,6 +142,8 @@ export function LlmSettingsLocalView() {+ // and would otherwise seed only the three hard-coded keys.+ const agentSchemaRef = useRef(agentSchema);+ agentSchemaRef.current = agentSchema;++ const settingsRef = useRef(settings);++ settingsRef.current = settings;++ // Provider connections are available on the local agent-server and on cloud+ // when an org is bound (the org-scoped CRUD routes). A cloud backend without+@@ -137,6 +163,7 @@ export function LlmSettingsLocalView() {+ const [saveControl, setSaveControl] = useState<SdkSectionSaveControl | null>(+ null,+ );++ const automaticCreateBooleanKeys = useRef<Set<string> | null>(null);+ const [isSaving, setIsSaving] = useState(false);+ const [isValidating, setIsValidating] = useState(false);++@@ -170,6 +197,7 @@ export function LlmSettingsLocalView() {+ }, []);++ const handleAddProfile = useCallback(() => {++ automaticCreateBooleanKeys.current = null;+ setProfileName("");+ setIsProfileNameUserEdited(false);+ setEditingProfile(null);+@@ -212,6 +240,7 @@ export function LlmSettingsLocalView() {+ );++ const handleBackToList = useCallback(() => {++ automaticCreateBooleanKeys.current = null;+ setViewMode("list");+ setEditingProfile(null);+ setProfileName("");+@@ -221,6 +250,31 @@ export function LlmSettingsLocalView() {+ const handleSaveControlChange = useCallback(+ (control: SdkSectionSaveControl) => {+ setSaveControl(control);++ const currentSettings = settingsRef.current;++ const currentSchema = agentSchemaRef.current;++ // Capture the draft's raw origin once it hydrates. Null-default booleans++ // render unchecked, but null preserves provider auto-detection. A later++ // settings refresh must not change that meaning for this open draft.++ if (++ viewMode === "create" &&++ automaticCreateBooleanKeys.current === null &&++ currentSettings &&++ currentSchema &&++ "llm.model" in control.values++ ) {++ automaticCreateBooleanKeys.current = new Set(++ currentSchema.sections.flatMap((section) =>++ section.fields++ .filter(++ (field) =>++ field.value_type === "boolean" &&++ field.default === null &&++ getAgentSettingValue(currentSettings, field.key) === null,++ )++ .map((field) => field.key),++ ),++ );++ }++ // Auto-derive profile name from model in create mode, and keep it+ // following later model changes until the user types their own name.+@@ -243,6 +297,7 @@ export function LlmSettingsLocalView() {+ [viewMode, isProfileNameUserEdited, existingNames],+ );+++ // @spec LLP-001 — New profiles preserve options and credential boundaries.+ const handleSave = useCallback(async () => {+ if (!saveControl || !isNameValid) return;++@@ -253,10 +308,34 @@ export function LlmSettingsLocalView() {+ // otherwise reset everything else to defaults.+ let dirtyLlm: Record<string, unknown>;+ try {+- dirtyLlm = (saveControl.getDirtyPayload().llm ?? {}) as Record<+- string,+- unknown+- >;++ // A new profile has no saved config to merge over, so persist every++ // non-secret value its form displays, using the same coercion as edits.++ // Explicit credential edits are included by the dirty payload below.++ const initialPayload =++ viewMode === "create" && agentSchema++ ? buildSdkSettingsPayload(++ agentSchema,++ saveControl.values,++ Object.fromEntries(++ agentSchema.sections.flatMap((section) =>++ section.fields++ .filter((field) => field.key in saveControl.values)++ .map((field) => [++ field.key,++ !field.secret &&++ !automaticCreateBooleanKeys.current?.has(field.key),++ ]),++ ),++ ),++ )++ : {};++ dirtyLlm = {++ ...((initialPayload.llm ?? {}) as Record<string, unknown>),++ ...((saveControl.getDirtyPayload().llm ?? {}) as Record<++ string,++ unknown++ >),++ };+ } catch (error) {+ displayErrorToast(+ error instanceof Error ? error.message : t(I18nKey.ERROR$GENERIC),+@@ -348,6 +427,7 @@ export function LlmSettingsLocalView() {+ }+ }, [+ saveControl,++ agentSchema,+ isNameValid,+ supportsConnections,+ profileName,+@@ -435,16 +515,7 @@ export function LlmSettingsLocalView() {+ viewMode === "edit" && editingProfile?.initialValues+ ? // Edit mode: use the existing profile values+ editingProfile.initialValues+- : // Create mode: prefill with the backend-selected default model,+- // while keeping secret/base URL fields blank for a fresh profile.+- {+- "llm.model": createProfileDefaultModel,+- "llm.api_key": "",+- "llm.base_url": "",+- [LLM_PROVIDER_CONNECTION_KEY]: "",+- [LLM_AUTH_TYPE_KEY]: LLM_AUTH_TYPE_API_KEY,+- [LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,+- }++ : createProfileInitialValues+ }+ showProviderConnection={supportsConnections}+ onSaveControlChange={handleSaveControlChange}+</pre></details></section><footer>I am an AI agent helping Engel Nyst (@enyst) with project maintenance.<br>Before bdb69754a113e3458d3645dfba0676ae73f4ebc3 · after 13da51daff35ae685f8fe13d3723b69c8464ab76. Temporary .pr review artifact; source links are commit-pinned. Same-repository cleanup-on-approval workflow is present.</footer></main></div></body></html>\ No newline at end of filediff --git a/.pr/17955/evidence/F10.create-prefill/inherited-after-save-2.png b/.pr/17955/evidence/F10.create-prefill/inherited-after-save-2.pngnew file mode 100644index 0000000000..ac333095f7Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-after-save-2.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-after-save.png b/.pr/17955/evidence/F10.create-prefill/inherited-after-save.pngnew file mode 100644index 0000000000..ac333095f7Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-after-save.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-before-save-2.png b/.pr/17955/evidence/F10.create-prefill/inherited-before-save-2.pngnew file mode 100644index 0000000000..7dc27e0b04Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-before-save-2.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-before-save.png b/.pr/17955/evidence/F10.create-prefill/inherited-before-save.pngnew file mode 100644index 0000000000..7dc27e0b04Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-before-save.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save-2.gif b/.pr/17955/evidence/F10.create-prefill/inherited-save-2.gifnew file mode 100644index 0000000000..5c4252f517Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-save-2.gif differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save-2.mp4 b/.pr/17955/evidence/F10.create-prefill/inherited-save-2.mp4new file mode 100644index 0000000000..960cb82a8bBinary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-save-2.mp4 differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save.gif b/.pr/17955/evidence/F10.create-prefill/inherited-save.gifnew file mode 100644index 0000000000..1636f2faf5Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-save.gif differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save.mp4 b/.pr/17955/evidence/F10.create-prefill/inherited-save.mp4new file mode 100644index 0000000000..aa725a9e6bBinary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/inherited-save.mp4 differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save-2.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save-2.pngnew file mode 100644index 0000000000..b85338edf4Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save-2.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save.pngnew file mode 100644index 0000000000..b85338edf4Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save-2.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save-2.pngnew file mode 100644index 0000000000..9a59a04f4fBinary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save-2.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save.pngnew file mode 100644index 0000000000..9a59a04f4fBinary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save.png differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.gif b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.gifnew file mode 100644index 0000000000..88105d3870Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.gif differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.mp4 b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.mp4new file mode 100644index 0000000000..0e5e1b88feBinary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.mp4 differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.gif b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.gifnew file mode 100644index 0000000000..9a198d5e3dBinary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.gif differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.mp4 b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.mp4new file mode 100644index 0000000000..7d20c9b7e0Binary files /dev/null and b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.mp4 differdiff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.jsonnew file mode 100644index 0000000000..60332801fb--- /dev/null+++ b/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json@@ -0,0 +1,29 @@+{+ "id": "F10.create-prefill",+ "name": "desktop-inherited",+ "exitCode": 0,+ "timedOut": false,+ "failedLine": null,+ "elapsedMs": 7086,+ "asserts": [+ {+ "ts": "2026-10-13T06:51:56.476Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "command": "browser value testid=sdk-settings-llm.temperature"+ },+ {+ "ts": "2026-10-13T06:52:01.349Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "bugShows": "",+ "command": "browser value testid=sdk-settings-llm.temperature"+ }+ ]+}diff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.jsonnew file mode 100644index 0000000000..fc1a78a93c--- /dev/null+++ b/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json@@ -0,0 +1,29 @@+{+ "id": "F10.create-prefill",+ "name": "desktop-inherited",+ "exitCode": 0,+ "timedOut": false,+ "failedLine": null,+ "elapsedMs": 6276,+ "asserts": [+ {+ "ts": "2026-10-13T06:52:06.252Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "command": "browser value testid=sdk-settings-llm.temperature"+ },+ {+ "ts": "2026-10-13T06:52:10.415Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "bugShows": "",+ "command": "browser value testid=sdk-settings-llm.temperature"+ }+ ]+}diff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.jsonnew file mode 100644index 0000000000..250dcddb12--- /dev/null+++ b/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json@@ -0,0 +1,29 @@+{+ "id": "F10.create-prefill",+ "name": "phone-inherited",+ "exitCode": 0,+ "timedOut": false,+ "failedLine": null,+ "elapsedMs": 5371,+ "asserts": [+ {+ "ts": "2026-10-13T06:52:15.014Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "command": "browser value testid=sdk-settings-llm.temperature"+ },+ {+ "ts": "2026-10-13T06:52:18.464Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "bugShows": "",+ "command": "browser value testid=sdk-settings-llm.temperature"+ }+ ]+}diff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.jsonnew file mode 100644index 0000000000..0d1ff02f71--- /dev/null+++ b/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json@@ -0,0 +1,29 @@+{+ "id": "F10.create-prefill",+ "name": "phone-inherited",+ "exitCode": 0,+ "timedOut": false,+ "failedLine": null,+ "elapsedMs": 5728,+ "asserts": [+ {+ "ts": "2026-10-13T06:52:23.235Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "command": "browser value testid=sdk-settings-llm.temperature"+ },+ {+ "ts": "2026-10-13T06:52:26.922Z",+ "ok": true,+ "kind": "hold",+ "actual": "0.4",+ "field": "value",+ "expected": "0.4",+ "bugShows": "",+ "command": "browser value testid=sdk-settings-llm.temperature"+ }+ ]+}diff --git a/.pr/17955/evidence/known-bugs/attempts.jsonl b/.pr/17955/evidence/known-bugs/attempts.jsonlnew file mode 100644index 0000000000..12025ffdd8--- /dev/null+++ b/.pr/17955/evidence/known-bugs/attempts.jsonl@@ -0,0 +1,4 @@+{"ts": "2026-10-13T06:52:01.394Z", "id": "F10.create-prefill", "name": "desktop-inherited", "label": "fix", "attempt": 1, "status": "xpass", "sha": "e54c2d729c903f2e", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 7086, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000", "transcript": "evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json"}+{"ts": "2026-10-13T06:52:10.422Z", "id": "F10.create-prefill", "name": "desktop-inherited", "label": "fix", "attempt": 2, "status": "xpass", "sha": "e54c2d729c903f2e", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 6276, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000", "transcript": "evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json"}+{"ts": "2026-10-13T06:52:18.471Z", "id": "F10.create-prefill", "name": "phone-inherited", "label": "fix", "attempt": 1, "status": "xpass", "sha": "ac0fc74c6cb76849", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 5371, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844", "transcript": "evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json"}+{"ts": "2026-10-13T06:52:26.928Z", "id": "F10.create-prefill", "name": "phone-inherited", "label": "fix", "attempt": 2, "status": "xpass", "sha": "ac0fc74c6cb76849", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 5728, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844", "transcript": "evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json"}diff --git a/.pr/17955/evidence/ledger.jsonl b/.pr/17955/evidence/ledger.jsonlnew file mode 100644index 0000000000..c3a34fd581--- /dev/null+++ b/.pr/17955/evidence/ledger.jsonl@@ -0,0 +1,4 @@+{"ts": "2026-10-13T06:52:01.394Z", "feature": "F10.create-prefill", "entry": "known bug: desktop-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 1", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000"}+{"ts": "2026-10-13T06:52:10.422Z", "feature": "F10.create-prefill", "entry": "known bug: desktop-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 2", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000"}+{"ts": "2026-10-13T06:52:18.471Z", "feature": "F10.create-prefill", "entry": "known bug: phone-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 1", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844"}+{"ts": "2026-10-13T06:52:26.928Z", "feature": "F10.create-prefill", "entry": "known bug: phone-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 2", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844"}diff --git a/__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx b/__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsxnew file mode 100644index 0000000000..bac0100188--- /dev/null+++ b/__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx@@ -0,0 +1,215 @@+import { act, screen, waitFor } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import userEvent from "@testing-library/user-event";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { renderWithProviders } from "test-utils";+import { LlmSettingsLocalView } from "#/components/features/settings/llm-profiles/llm-settings-local-view";+import SettingsService from "#/api/settings-service/settings-service.api";+import ProfilesService from "#/api/profiles-service/profiles-service.api";+import ProviderConnectionsService from "#/api/provider-connections-service/provider-connections-service.api";+import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";+import { useFreeModelsStore } from "#/stores/free-models-store";+import { SETTINGS_QUERY_KEYS } from "#/hooks/query/query-keys";++describe("LLM profile creation with the real embedded form", () => {+ let inheritedStringSerializer: boolean | null | undefined;+ beforeEach(() => {+ vi.restoreAllMocks();+ inheritedStringSerializer = null;+ useFreeModelsStore+ .getState()+ .setFlags({ freeModels: new Set(), defaultModel: "openai/gpt-4o" });+ vi.spyOn(ProfilesService, "listProfiles").mockResolvedValue({+ profiles: [],+ active_profile: null,+ });+ vi.spyOn(ProfilesService, "validateProfile").mockResolvedValue({+ valid: true,+ });+ vi.spyOn(ProviderConnectionsService, "list").mockResolvedValue([]);+ vi.spyOn(SettingsService, "getSettings").mockImplementation(async () => ({+ ...MOCK_DEFAULT_USER_SETTINGS,+ agent_settings_schema: {+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings_schema!,+ sections:+ MOCK_DEFAULT_USER_SETTINGS.agent_settings_schema!.sections.map(+ (section) =>+ section.key === "llm"+ ? {+ ...section,+ fields: [+ ...section.fields,+ {+ key: "llm.aws_secret_access_key",+ label: "AWS secret access key",+ description: "Optional provider credential",+ section: "llm",+ section_label: "LLM",+ value_type: "string" as const,+ default: null,+ secret: true,+ required: false,+ depends_on: [],+ prominence: "minor" as const,+ choices: [],+ },+ {+ key: "llm.force_string_serializer",+ label: "Force string serializer",+ description: "Null selects automatic model detection",+ section: "llm",+ section_label: "LLM",+ value_type: "boolean" as const,+ default: null,+ secret: false,+ required: false,+ depends_on: [],+ prominence: "minor" as const,+ choices: [],+ },+ ],+ }+ : section,+ ),+ },+ agent_settings: {+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,+ llm: {+ model: "anthropic/claude-sonnet",+ api_key: "another-profile-key",+ base_url: "https://another-profile.example/v1",+ temperature: 0.4,+ aws_secret_access_key: "**********",+ ...(inheritedStringSerializer === undefined+ ? {}+ : { force_string_serializer: inheritedStringSerializer }),+ },+ },+ }));+ });++ // @spec LLP-001 — New profiles preserve options and credential boundaries.+ it("saves an untouched displayed option without inheriting another profile's credentials", async () => {+ // Arrange: existing agent settings have a non-default option and credentials.+ const save = vi+ .spyOn(ProfilesService, "saveProfile")+ .mockResolvedValue({ name: "QA_Inherited", message: "Saved" });+ const user = userEvent.setup();+ renderWithProviders(<LlmSettingsLocalView />);++ // Act: create a profile, keeping its displayed temperature unchanged.+ await user.click(await screen.findByTestId("add-llm-profile"));+ await user.click(await screen.findByTestId("sdk-section-all-toggle"));+ expect(screen.getByTestId("sdk-settings-llm.temperature")).toHaveValue(0.4);+ expect(screen.getByTestId("llm-api-key-input")).toHaveValue("");+ expect(screen.getByTestId("base-url-input")).toHaveValue("");+ expect(+ screen.getByTestId("sdk-settings-llm.aws_secret_access_key"),+ ).toHaveValue("");+ await user.clear(screen.getByTestId("profile-name-input"));+ await user.type(screen.getByTestId("profile-name-input"), "QA_Inherited");+ await user.type(screen.getByTestId("llm-api-key-input"), "new-profile-key");+ await user.click(screen.getByTestId("save-profile-btn"));++ // Assert: the real schema form's coerced option reaches profile persistence.+ await waitFor(() =>+ expect(save).toHaveBeenCalledWith("QA_Inherited", {+ llm: expect.objectContaining({+ model: "openai/gpt-4o",+ api_key: "new-profile-key",+ temperature: 0.4,+ }),+ include_secrets: true,+ }),+ );+ expect(save.mock.calls[0][1].llm.base_url).not.toBe(+ "https://another-profile.example/v1",+ );+ expect(save.mock.calls[0][1].llm.aws_secret_access_key).toBeUndefined();+ });++ // @spec LLP-001 — Preserve automatic nullable booleans and explicit overrides.+ it.each([+ {+ name: "untouched automatic null",+ initial: null,+ edit: false,+ refresh: undefined,+ expected: undefined,+ },+ {+ name: "untouched omitted automatic value",+ initial: undefined,+ edit: false,+ refresh: undefined,+ expected: undefined,+ },+ {+ name: "inherited explicit false",+ initial: false,+ edit: false,+ refresh: undefined,+ expected: false,+ },+ {+ name: "explicit dirty edit",+ initial: null,+ edit: true,+ refresh: undefined,+ expected: true,+ },+ {+ name: "inherited false after settings refresh",+ initial: false,+ edit: false,+ refresh: null,+ expected: false,+ },+ ])(+ "keeps $name in the new profile",+ async ({ initial, edit, refresh, expected }) => {+ // Arrange: null and false render alike but have different provider meaning.+ inheritedStringSerializer = initial;+ const save = vi+ .spyOn(ProfilesService, "saveProfile")+ .mockResolvedValue({ name: "QA_Boolean", message: "Saved" });+ const user = userEvent.setup();+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ renderWithProviders(+ <QueryClientProvider client={queryClient}>+ <LlmSettingsLocalView />+ </QueryClientProvider>,+ );+ await user.click(await screen.findByTestId("add-llm-profile"));+ await user.click(await screen.findByTestId("sdk-section-all-toggle"));+ const checkbox = screen.getByTestId(+ "sdk-settings-llm.force_string_serializer",+ );+ expect(checkbox).not.toBeChecked();++ // Act: save untouched, or explicitly edit, without re-seeding the open draft.+ if (refresh !== undefined) {+ inheritedStringSerializer = refresh;+ await act(async () => {+ await queryClient.invalidateQueries({+ queryKey: SETTINGS_QUERY_KEYS.byScope("personal"),+ });+ });+ }+ if (edit) await user.click(checkbox.closest("label")!);+ await user.clear(screen.getByTestId("profile-name-input"));+ await user.type(screen.getByTestId("profile-name-input"), "QA_Boolean");+ await user.type(+ screen.getByTestId("llm-api-key-input"),+ "new-profile-key",+ );+ await user.click(screen.getByTestId("save-profile-btn"));++ // Assert: the saved request preserves auto-detection, false or the dirty true.+ await waitFor(() => expect(save).toHaveBeenCalled());+ expect(save.mock.calls[0][1].llm.force_string_serializer).toBe(expected);+ },+ );+});diff --git a/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx b/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsxindex 1a2f4a1fc8..bd2b523393 100644--- a/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx+++ b/__tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx@@ -73,6 +73,7 @@ vi.mock("#/routes/llm-settings", async () => {"llm.model": model,"llm.api_key": apiKey,"llm.base_url": baseUrl,+ "llm.temperature": temperature,};onSaveControlChange?.({save: vi.fn(),diff --git a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsxindex dbb7ab5244..c0a562a5b3 100644--- a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx+++ b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx@@ -47,7 +47,11 @@ import {LLM_SUBSCRIPTION_VENDOR_KEY,OPENAI_SUBSCRIPTION_VENDOR,} from "#/constants/llm-subscription";-import { SettingsFormValues } from "#/utils/sdk-settings-schema";+import {+ buildSdkSettingsPayload,+ getAgentSettingValue,+ SettingsFormValues,+} from "#/utils/sdk-settings-schema";import { BackNavButton } from "#/components/shared/buttons/back-nav-button";import { Typography } from "#/ui/typography";import { useSettingsSectionHeader } from "#/contexts/settings-section-header-context";@@ -109,6 +113,26 @@ export function LlmSettingsLocalView() {// embedded form hydrates, so the eventual DB default never replaces it and// the user can save the wrong model.const isDefaultModelReady = useDefaultModelReady();+ // @spec LLP-001 — A fresh profile never inherits schema-declared credentials.+ const createProfileInitialValues = useMemo(+ () => ({+ // A fresh profile may inherit options, but no existing credentials.+ ...Object.fromEntries(+ (agentSchema?.sections ?? []).flatMap((section) =>+ section.fields+ .filter((field) => field.secret)+ .map((field) => [field.key, ""]),+ ),+ ),+ "llm.model": createProfileDefaultModel,+ "llm.api_key": "",+ "llm.base_url": "",+ [LLM_PROVIDER_CONNECTION_KEY]: "",+ [LLM_AUTH_TYPE_KEY]: LLM_AUTH_TYPE_API_KEY,+ [LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,+ }),+ [agentSchema, createProfileDefaultModel],+ );// Always hold the freshest schema. `handleEditProfile` awaits a network// round-trip before seeding the form, so reading the schema from a ref@@ -118,6 +142,8 @@ export function LlmSettingsLocalView() {// and would otherwise seed only the three hard-coded keys.const agentSchemaRef = useRef(agentSchema);agentSchemaRef.current = agentSchema;+ const settingsRef = useRef(settings);+ settingsRef.current = settings;// Provider connections are available on the local agent-server and on cloud// when an org is bound (the org-scoped CRUD routes). A cloud backend without@@ -137,6 +163,7 @@ export function LlmSettingsLocalView() {const [saveControl, setSaveControl] = useState<SdkSectionSaveControl | null>(null,);+ const automaticCreateBooleanKeys = useRef<Set<string> | null>(null);const [isSaving, setIsSaving] = useState(false);const [isValidating, setIsValidating] = useState(false);@@ -170,6 +197,7 @@ export function LlmSettingsLocalView() {}, []);const handleAddProfile = useCallback(() => {+ automaticCreateBooleanKeys.current = null;setProfileName("");setIsProfileNameUserEdited(false);setEditingProfile(null);@@ -212,6 +240,7 @@ export function LlmSettingsLocalView() {);const handleBackToList = useCallback(() => {+ automaticCreateBooleanKeys.current = null;setViewMode("list");setEditingProfile(null);setProfileName("");@@ -221,6 +250,31 @@ export function LlmSettingsLocalView() {const handleSaveControlChange = useCallback((control: SdkSectionSaveControl) => {setSaveControl(control);+ const currentSettings = settingsRef.current;+ const currentSchema = agentSchemaRef.current;+ // Capture the draft's raw origin once it hydrates. Null-default booleans+ // render unchecked, but null preserves provider auto-detection. A later+ // settings refresh must not change that meaning for this open draft.+ if (+ viewMode === "create" &&+ automaticCreateBooleanKeys.current === null &&+ currentSettings &&+ currentSchema &&+ "llm.model" in control.values+ ) {+ automaticCreateBooleanKeys.current = new Set(+ currentSchema.sections.flatMap((section) =>+ section.fields+ .filter(+ (field) =>+ field.value_type === "boolean" &&+ field.default === null &&+ getAgentSettingValue(currentSettings, field.key) === null,+ )+ .map((field) => field.key),+ ),+ );+ }// Auto-derive profile name from model in create mode, and keep it// following later model changes until the user types their own name.@@ -243,6 +297,7 @@ export function LlmSettingsLocalView() {[viewMode, isProfileNameUserEdited, existingNames],);+ // @spec LLP-001 — New profiles preserve options and credential boundaries.const handleSave = useCallback(async () => {if (!saveControl || !isNameValid) return;@@ -253,10 +308,34 @@ export function LlmSettingsLocalView() {// otherwise reset everything else to defaults.let dirtyLlm: Record<string, unknown>;try {- dirtyLlm = (saveControl.getDirtyPayload().llm ?? {}) as Record<- string,- unknown- >;+ // A new profile has no saved config to merge over, so persist every+ // non-secret value its form displays, using the same coercion as edits.+ // Explicit credential edits are included by the dirty payload below.+ const initialPayload =+ viewMode === "create" && agentSchema+ ? buildSdkSettingsPayload(+ agentSchema,+ saveControl.values,+ Object.fromEntries(+ agentSchema.sections.flatMap((section) =>+ section.fields+ .filter((field) => field.key in saveControl.values)+ .map((field) => [+ field.key,+ !field.secret &&+ !automaticCreateBooleanKeys.current?.has(field.key),+ ]),+ ),+ ),+ )+ : {};+ dirtyLlm = {+ ...((initialPayload.llm ?? {}) as Record<string, unknown>),+ ...((saveControl.getDirtyPayload().llm ?? {}) as Record<+ string,+ unknown+ >),+ };} catch (error) {displayErrorToast(error instanceof Error ? error.message : t(I18nKey.ERROR$GENERIC),@@ -348,6 +427,7 @@ export function LlmSettingsLocalView() {}}, [saveControl,+ agentSchema,isNameValid,supportsConnections,profileName,@@ -435,16 +515,7 @@ export function LlmSettingsLocalView() {viewMode === "edit" && editingProfile?.initialValues? // Edit mode: use the existing profile valueseditingProfile.initialValues- : // Create mode: prefill with the backend-selected default model,- // while keeping secret/base URL fields blank for a fresh profile.- {- "llm.model": createProfileDefaultModel,- "llm.api_key": "",- "llm.base_url": "",- [LLM_PROVIDER_CONNECTION_KEY]: "",- [LLM_AUTH_TYPE_KEY]: LLM_AUTH_TYPE_API_KEY,- [LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,- }+ : createProfileInitialValues}showProviderConnection={supportsConnections}onSaveControlChange={handleSaveControlChange}