Skip to content
This repository was archived by the owner on Jul 27, 2026. It is now read-only.

feat: allow changing the LLM profile when editing an automation - #1527

Merged
hieptl merged 2 commits into
mainfrom
hieptl/app-2517
Jun 29, 2026
Merged

hieptl merged 2 commits into
mainfrom
hieptl/app-2517

Conversation

@hieptl

@hieptl hieptl commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

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 model in 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.

  • A human has tested these changes.

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 model field; the PATCH /api/automation/v1/{id} endpoint accepts and validates model (UpdateAutomationRequest.model → resolve_model_profile_for_user); and the run dispatcher reads automation.model and passes it to every run via the AUTOMATION_MODEL env 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

  • The Edit Automation modal shows an "LLM profile" dropdown listing the user's saved profiles.
  • The dropdown is pre-selected to the automation's current profile.
  • Selecting a different profile and saving persists it; the detail page then shows the new profile and future runs use it.
  • Saving without touching the profile does NOT send model (the profile is never changed or reset accidentally).
  • The dropdown is hidden when the user has no profiles (consistent with the in-chat switch-profile control).
  • Editing only name / prompt / schedule continues to work unchanged.

Out of scope

  • Creating an automation with a profile (creation happens via the in-chat skill, not a form).
  • An explicit "reset to active profile" (null) option — the picker offers concrete profiles only.
  • Any backend, schema, or API changes (already in place).

Notes

  • Reuse useLlmProfiles() and the existing SettingsDropdownInput.
  • Reuse existing i18n keys AUTOMATIONS$DETAIL$MODEL ("LLM profile") and COMMON$ACTIVE_PROFILE ("Active profile") — no new strings.

Testing

  • Automated: extend edit-automation-modal.test.tsx.
  • Manual: open an automation → Edit → change the LLM profile → Save → verify the detail page reflects the new profile.

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.model stores the profile name.
  • PATCH /api/automation/v1/{id} accepts and validates model (UpdateAutomationRequest.model → resolve_model_profile_for_user).
  • The dispatcher reads automation.model and 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 model to the form state, seeded from automation.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 model in 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

  • Pre-selects the automation's current profile.
  • Unchanged profile → model is omitted from the request (no accidental change).
  • Legacy automation with no profile → shows the "Active profile" placeholder; leaving it untouched sends nothing.
  • No profiles available → picker is not shown.

Issue Number

Resolves #2005

How to Test

  1. Open an automation → Edit. Confirm an LLM profile dropdown appears, pre-selected to the current profile and listing your saved profiles.
  2. Pick a different profile → Save. Reopen the detail page and confirm the LLM profile field shows the new value (future runs use it).
  3. Reopen Edit, change nothing, Save → the modal just closes; no update fires.
  4. Edit only name / prompt / schedule → still works and does not send 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

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

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

Component Value
Image ghcr.io/openhands/agent-canvas
Architectures amd64, arm64
Agent Server ghcr.io/openhands/agent-server:1.29.3-python
Automation openhands-automation==1.0.0a13
Commit b83599bd2884afdca2f26501a38700debfe7ef51

Pull (multi-arch manifest)

# Multi-arch manifest — Docker automatically pulls the correct architecture
docker pull ghcr.io/openhands/agent-canvas:sha-b83599b

Run

docker run -it --rm \
  -p 8000:8000 \
  ghcr.io/openhands/agent-canvas:sha-b83599b

All tags pushed for this build

ghcr.io/openhands/agent-canvas:sha-b83599b-amd64
ghcr.io/openhands/agent-canvas:hieptl-app-2517-amd64
ghcr.io/openhands/agent-canvas:pr-1527-amd64
ghcr.io/openhands/agent-canvas:sha-b83599b-arm64
ghcr.io/openhands/agent-canvas:hieptl-app-2517-arm64
ghcr.io/openhands/agent-canvas:pr-1527-arm64
ghcr.io/openhands/agent-canvas:sha-b83599b
ghcr.io/openhands/agent-canvas:hieptl-app-2517
ghcr.io/openhands/agent-canvas:pr-1527

About Multi-Architecture Support

  • Each tag (e.g., sha-b83599b) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., sha-b83599b-amd64) are also available if needed

@hieptl hieptl self-assigned this Jun 29, 2026
@vercel

vercel Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-canvas Ready Ready Preview, Comment Jun 29, 2026 6:10am

Request Review

all-hands-bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Mock-LLM E2E Tests

10/10 passed

Commit: b83599bd · Workflow run · Test artifacts

Details
Status Test Duration
✅ automations/mock-llm-automation.spec.ts › mock-LLM automation lifecycle › step 1: setup LLM profile and register automation trajectory 7.3s
✅ automations/mock-llm-automation.spec.ts › mock-LLM automation lifecycle › step 2: create automation and dispatch run via the UI 27.5s
✅ automations/mock-llm-automation.spec.ts › mock-LLM automation lifecycle › step 3: verify automation and run on the automations page 6.1s
✅ automations/mock-llm-preset-automation.spec.ts › preset automation → slash command conversation › automation card sends the correct slash command to a conversation 16.3s
✅ automations/mock-llm-preset-automation.spec.ts › preset automation → slash command conversation › direct slash command from home page triggers skill activation 13.4s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › scopes standalone styles to the agent-server-ui shell 1.3s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › renders critic results on agent messages and finish actions 1.5s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › loads older events when scrolling up 1.8s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › selected workspace persists after navigating away and returning 3.1s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › cleared sessionStorage yields empty workspace selection 1.5s

Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses)

@github-actions

Copy link
Copy Markdown
Contributor

✅ Mock-LLM Docker E2E Test Results

60/60 passed

Commit: b83599bd · Workflow run · Test artifacts

Details
Status Test Duration
✅ automations/mock-llm-automation.spec.ts › mock-LLM automation lifecycle › step 1: setup LLM profile and register automation trajectory 7.4s
✅ automations/mock-llm-automation.spec.ts › mock-LLM automation lifecycle › step 2: create automation and dispatch run via the UI 33.5s
✅ automations/mock-llm-automation.spec.ts › mock-LLM automation lifecycle › step 3: verify automation and run on the automations page 6.2s
✅ automations/mock-llm-preset-automation.spec.ts › preset automation → slash command conversation › automation card sends the correct slash command to a conversation 16.7s
✅ automations/mock-llm-preset-automation.spec.ts › preset automation → slash command conversation › direct slash command from home page triggers skill activation 13.4s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: fresh install with runtime-injected key › reaches the onboarding modal without pre-seeded localStorage 1.4s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: non-public key rotation › recovers when localStorage has a stale session API key 5.4s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: public gate › shows first-run onboarding before the auth screen when no key is configured 1.4s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: public gate › rejects an incorrect key with an inline error 1.7s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: public gate › allows access after pasting the correct key 1.9s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: public gate › skips auth screen for returning user with valid stored key 1.2s
✅ backends/mock-llm-auth-modes.spec.ts › auth mode: public gate › re-prompts when the server rotates its key (stale localStorage) 1.5s
✅ backends/mock-llm-cross-connect.spec.ts › cross-connect: frontend-only → backend-only › frontend-only connects to a separate backend-only instance 23.0s
✅ backends/mock-llm-cross-connect.spec.ts › cross-connect: frontend-only → multiple backends › connects to two separate backends and switches between them 20.9s
✅ backends/mock-llm-partial-stack.spec.ts › partial stack: --frontend-only › serves the frontend but returns 503 for backend routes 7.3s
✅ backends/mock-llm-partial-stack.spec.ts › partial stack: --backend-only › serves backend APIs but returns 503 for the frontend root 14.1s
✅ backends/mock-llm-partial-stack.spec.ts › partial stack: port conflict › fails with a clear error when the ingress port is occupied 103ms
✅ backends/mock-llm-partial-stack.spec.ts › partial stack: port conflict › starts successfully on a free port after a conflict 6.0s
✅ conversations/mock-llm-conversation.spec.ts › mock-LLM agent-server conversation › step 1: create an LLM profile pointing at the mock LLM server 6.3s
✅ conversations/mock-llm-conversation.spec.ts › mock-LLM agent-server conversation › step 2: activate the mock-llm profile and verify settings API 6.3s
✅ conversations/mock-llm-conversation.spec.ts › mock-LLM agent-server conversation › step 3: run a conversation with the mock LLM 6.6s
✅ conversations/mock-llm-conversation.spec.ts › mock-LLM agent-server conversation › step 4: resume conversation from sidebar after navigating away 5.9s
✅ conversations/mock-llm-image-upload.spec.ts › mock-LLM image upload › attaching an image embeds it as base64 in the LLM completion call 13.4s
✅ files/mock-llm-files-and-git.spec.ts › files tab, git control bar, and browser tab › step 1: ensure mock LLM profile is configured 7.3s
✅ files/mock-llm-files-and-git.spec.ts › files tab, git control bar, and browser tab › step 2: start conversation and attach workspace metadata 12.3s
✅ files/mock-llm-files-and-git.spec.ts › files tab, git control bar, and browser tab › step 3: git control bar shows workspace pill and git actions 5.4s
✅ files/mock-llm-files-and-git.spec.ts › files tab, git control bar, and browser tab › step 4: files tab defaults to diff view for attached workspace 5.9s
✅ files/mock-llm-files-and-git.spec.ts › files tab, git control bar, and browser tab › step 5: browser tab shows empty state 6.3s
✅ files/mock-llm-files-and-git.spec.ts › files tab, git control bar, and browser tab › step 6: files tab defaults to file-tree view without attached workspace 7.5s
✅ home/mock-llm-folder-workspace.spec.ts › mock-LLM folder browser → workspace → conversation › step 1: browse to a folder, add it as a workspace, and launch a conversation with the correct working_dir 7.5s
✅ mcp/mock-llm-mcp-github.spec.ts › MCP GitHub server install flow › step 1: GitHub card is visible on the MCP marketplace page 5.5s
✅ mcp/mock-llm-mcp-github.spec.ts › MCP GitHub server install flow › step 2: clicking GitHub card opens the install modal with correct fields 5.7s
✅ mcp/mock-llm-mcp-github.spec.ts › MCP GitHub server install flow › step 3: full install flow — fill PAT, submit, verify installed 13.1s
✅ mcp/mock-llm-mcp-github.spec.ts › MCP GitHub server install flow › step 4: installed GitHub server can be deleted 5.9s
✅ mcp/mock-llm-mcp-slack-credentials.spec.ts › MCP Test Connection credential verification (Slack) › install: invalid Slack credentials are blocked with a credential-check error 5.8s
✅ mcp/mock-llm-mcp-slack-credentials.spec.ts › MCP Test Connection credential verification (Slack) › install: a valid token missing only a scope still installs (missing_scope is not a credential failure) 5.9s
✅ mcp/mock-llm-mcp-slack-credentials.spec.ts › MCP Test Connection credential verification (Slack) › install: an older agent server that omits tool_result still installs (compat) 5.9s
✅ mcp/mock-llm-mcp-slack-credentials.spec.ts › MCP Test Connection credential verification (Slack) › edit: Test Connection verifies the stored credentials and surfaces a credential failure 5.8s
✅ mcp/mock-llm-mcp-slack-credentials.spec.ts › MCP Test Connection credential verification (Slack) › edit: Test Connection reports success for valid stored credentials 5.8s
✅ mcp/mock-llm-mcp-slack-credentials.spec.ts › MCP Test Connection credential verification (Slack) › custom (non-catalog) server: Test Connection attaches no verification probe 5.8s
✅ onboarding/mock-llm-onboarding-happy-path.spec.ts › onboarding happy path › completes the full onboarding flow and launches a conversation 3.6s
✅ onboarding/mock-llm-onboarding-regressions.spec.ts › onboarding recent regressions › keeps the modal open on backdrop click and Escape 1.5s
✅ onboarding/mock-llm-onboarding-regressions.spec.ts › onboarding recent regressions › defaults the LLM setup step to OpenAI GPT-5.5 1.6s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › scopes standalone styles to the agent-server-ui shell 1.4s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › renders critic results on agent messages and finish actions 1.5s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › loads older events when scrolling up 1.7s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › selected workspace persists after navigating away and returning 2.6s
✅ regressions/mock-llm-ui-regressions.spec.ts › UI regressions › cleared sessionStorage yields empty workspace selection 1.4s
✅ settings/mock-llm-acp-agent.spec.ts › mock-LLM ACP agent conversation › step 1: configure ACP agent via Settings → Agent UI 13.9s
✅ settings/mock-llm-acp-agent.spec.ts › mock-LLM ACP agent conversation › step 2: reload and verify ACP settings are persisted in UI 5.6s
✅ settings/mock-llm-acp-agent.spec.ts › mock-LLM ACP agent conversation › step 3: start ACP conversation and verify agent reply 6.8s
✅ settings/mock-llm-acp-agent.spec.ts › mock-LLM ACP agent conversation › step 4: resume ACP conversation from sidebar after navigating away 5.8s
✅ settings/mock-llm-model-switch.spec.ts › mock-LLM /model slash command › step 1: configure LLM, create switch-target profile, register trajectory 13.5s
✅ settings/mock-llm-model-switch.spec.ts › mock-LLM /model slash command › step 2: start conversation, switch profile via /model, verify switch 6.8s
✅ settings/mock-llm-profile-management.spec.ts › active profile deletion + reconciliation › active profile is deletable and reconciliation activates another profile 8.9s
✅ settings/mock-llm-profile-management.spec.ts › same-model profile identity › chat header shows the correct profile when two profiles share the same model 15.3s
✅ settings/mock-llm-profile-management.spec.ts › OpenHands provider hidden base_url preservation › re-saving an OpenHands profile from Basic view preserves hidden base_url 7.4s
✅ skills/mock-llm-skills.spec.ts › skill loading: project, user, and deletion › project skill in workspace/.agents/skills/ triggers on matching keyword 13.8s
✅ skills/mock-llm-skills.spec.ts › skill loading: project, user, and deletion › user skill in ~/.openhands/skills/ triggers on matching keyword 13.5s
✅ skills/mock-llm-skills.spec.ts › skill loading: project, user, and deletion › deleting a user skill removes it from subsequent conversations 13.5s

Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses)

@hieptl
hieptl merged commit 69e7546 into main Jun 29, 2026
19 checks passed
@hieptl
hieptl deleted the hieptl/app-2517 branch June 29, 2026 06:24
@openhands-release-bot openhands-release-bot Bot added the released: v1.2.0 Shipped in v1.2.0 label Jul 9, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in v1.2.0.

This branch was successfully deployed

1 active deployment
Preview — b83599bd Deployed Jun 29, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow switching LLM Profile (Agent Profile later) per automation after creation

2 participants