Repository navigation
feat: allow changing the LLM profile when editing an automation - #1527
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste — Elegant, minimal, additive change with no backend surface touched.
This PR threads the needle well: the backend already persisted and honored automation.model; the only gap was the UI, and this fills it with the exact right footprint. useLlmProfiles + SettingsDropdownInput reuse existing infrastructure, the guard selectedModel && selectedModel !== (automation.model ?? "") correctly avoids accidental null-writes, and hiding the picker when profiles is empty matches the precedent set by switch-profile-button.
The three new tests cover the three behaviors that matter — profile persists, unchanged profile omits, empty list hides — and they exercise real UI interactions rather than just mocking assertions. Evidence is provided via video.
[RISK ASSESSMENT]
- [Overall PR]
⚠️ Risk Assessment: 🟢 LOW
Frontend-only, single-component, additive change. No backend, schema, service, or API surface was modified. Existing edit flows are guarded by the unchanged tests and the conservative PATCH guard ensures no accidental profile resets.
VERDICT:
✅ Worth merging — Core logic is sound, no issues found.
KEY INSIGHT:
The update guard selectedModel && selectedModel !== (automation.model ?? "") is the critical invariant: it makes the picker a true opt-in change, never silently resetting a profile to null on unrelated saves.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
✅ Mock-LLM E2E Tests10/10 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
✅ Mock-LLM Docker E2E Test Results60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
|
🚀 Released in v1.2.0. |
HUMAN:
Add an "LLM profile" selector to the Edit Automation modal so users can choose which profile future runs use. The data model and backend already persisted and honored the automation's
model(profile name): the PATCH endpoint validates it via resolve_model_profile_for_user and the dispatcher passes it to every run as AUTOMATION_MODEL. The modal simply never exposed it.The form now loads the user's profiles with useLlmProfiles, reuses SettingsDropdownInput to render the picker, pre-selects the automation's current profile, and includes
modelin the PATCH body only when a concrete profile is chosen and it differs from the current value — so untouched automations are never modified and the profile is never reset to null. The picker is hidden when no profiles exist, matching the in-chat switch-profile control. No backend, schema, service, type, or i18n changes were needed.Tests: extend edit-automation-modal.test.tsx to cover persisting a changed profile, omitting an unchanged profile from the payload, and hiding the picker when no profiles are available.
AGENT:
Why
Users can edit an automation's name, prompt, and schedule, but not the LLM profile it runs with. The detail page already shows the profile read-only ("LLM profile" → falls back to "Active profile" when unset), yet there is no way to change it after creation.
The persistence and runtime layers already support this end-to-end: an automation stores its profile name in the
modelfield; thePATCH /api/automation/v1/{id}endpoint accepts and validatesmodel(UpdateAutomationRequest.model→resolve_model_profile_for_user); and the run dispatcher readsautomation.modeland passes it to every run via theAUTOMATION_MODELenv var / event payload. The only gap is the UI.User story
As a user managing an automation, I want to change its LLM profile from the Edit dialog so that all future runs use the profile I select.
Acceptance criteria
model(the profile is never changed or reset accidentally).Out of scope
Notes
useLlmProfiles()and the existingSettingsDropdownInput.AUTOMATIONS$DETAIL$MODEL("LLM profile") andCOMMON$ACTIVE_PROFILE("Active profile") — no new strings.Testing
edit-automation-modal.test.tsx.Summary
Adds an LLM profile selector to the Edit Automation modal so users can change which profile an automation uses for all future runs. This is a frontend-only change — the backend already persisted and honored the automation's profile.
Why
The Edit modal let users change name, prompt, and schedule, but not the LLM profile, even though the detail page displays it read-only. Everything downstream was already wired:
Automation.modelstores the profile name.PATCH /api/automation/v1/{id}accepts and validatesmodel(UpdateAutomationRequest.model→resolve_model_profile_for_user).automation.modeland passes it to each run (AUTOMATION_MODEL).The only missing piece was the UI control.
What changed
edit-automation-modal.tsx:Load available profiles with
useLlmProfiles().Add
modelto the form state, seeded fromautomation.model.Render an "LLM profile" dropdown (reusing
SettingsDropdownInput, the same component the form uses for frequency), placed above the trigger/schedule block so it applies to both scheduled and event automations.Include
modelin the PATCH body only when a concrete profile is selected and it differs from the current value (never resets to null).Hide the picker when no profiles exist, matching
switch-profile-button.Reuses existing i18n keys (
AUTOMATIONS$DETAIL$MODEL,COMMON$ACTIVE_PROFILE) — no new strings.No backend / schema / service / type changes.
Behavior & edge cases
modelis omitted from the request (no accidental change).Issue Number
Resolves #2005
How to Test
model.Automated:
npx vitest run __tests__/components/automations/detail/edit-automation-modal.test.tsx(7 passing: 4 existing + 3 new — change persists, unchanged omitted, picker hidden when no profiles).npm run lint(typecheck + eslint + prettier) is green.Video/Screenshots
app-2517.mov
Type
Notes
Risk
Low. Single-component, additive change; no backend or API surface touched. Existing edit flows are covered by the unchanged tests.
🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.29.3-pythonopenhands-automation==1.0.0a13b83599bd2884afdca2f26501a38700debfe7ef51Pull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-b83599bRun
All tags pushed for this build
About Multi-Architecture Support
sha-b83599b) is a multi-arch manifest supporting both amd64 and arm64sha-b83599b-amd64) are also available if needed