Repository navigation
Description
Summary
Generalize the existing LLM Profiles feature into Agent Profiles: a library of named, reusable agent setups that capture everything about how an agent runs — which agent (built-in OpenHands vs. an ACP CLI), the model + credentials, MCP servers, skills, and personality (system-prompt suffix / condenser / verification). Users pick a profile when starting a conversation and, where it's safe, switch profiles or just the model mid-conversation.
This is a design proposal / RFC. It is opinionated and deliberately diverges from the earlier drafts (see Prior art). The headline recommendation:
An Agent Profile is a named, self-contained
AgentSettingsConfig(the SDK union we already have) plus a small launch-defaults slice — with secrets referenced and config embedded. No new foreign-key graph between profile types.
Everything below argues why that shape beats the alternatives the current code keeps nudging us toward, and lays out a local-first plan.
1. Why this matters (product framing)
Today there is one global agent config plus a side-dict of LLM profiles that only swap the model. So a user who wants "Claude Opus + my MCP servers + verification on" for hard tasks and "cheap GPT, no MCP" for daily driving has no first-class way to save and switch between those whole setups — and with ACP now in the picture, which agent (Claude Code vs Codex vs the native CodeAct agent) is itself a setting worth saving.
The mental model we want: Settings → Agents is a library of named launch recipes. Pick one to start a conversation; switch live when the running session can absorb the change; otherwise offer "start a new conversation with this profile." Never silently apply half a profile.
2. Current state (what we build on — verified against main)
The substrate is already most of the way there; the profile layer just doesn't use it.
The SDK already has the execution model (openhands-sdk/openhands/sdk/settings/model.py):
AgentSettingsConfig = OpenHandsAgentSettings | ACPAgentSettings | LLMAgentSettings(legacy)— a discriminated union onagent_kind(model.py:1790). This is already "a full agent setup," first-class and discriminated.OpenHandsAgentSettings(:956):agent, llm, tools, enable_sub_agents, enable_switch_llm_tool, tool_concurrency_limit, mcp_config, agent_context (skills + suffixes), condenser, verification.ACPAgentSettings(:1200):acp_server, acp_command, acp_args, acp_env(dep), acp_model, acp_session_mode, acp_prompt_timeout, mcp_config, acp_isolate_data_dir, acp_file_secrets, llm(dep — attribution only).apply_agent_settings_diff(base, diff)(:1861) — one-wayagent_kindnarrowing (kind change → fresh base; same kind → RFC-7386 merge-patch). The discriminator is a narrowing gate, never a conversion knob.export_agent_settings_schema()(:1919) — variant-tagged sections (SettingsFieldMetadata.variant) that the canvas settings forms already render from.acp_providers.py:386—ACP_PROVIDERSencodessupports_runtime_model_switch,api_key_env_var,base_url_env_var,available_models,default_model,file_secrets,data_dir_env_var. Exactly the capability data a "can I switch live?" decision needs.
Profiles today are LLM-only, across two parallel stores:
- Local:
LLMProfileStore—~/.openhands/profiles/{name}.json, file-locked, schema-versioned, cipher-encrypted; stores a bareLLM. Router/api/profiles(CRUD +/activate). Active pointer =PersistedSettings.active_profile. - App-server:
Settings.llm_profiles: LLMProfiles{profiles: dict[str,LLM], active}(app_server/settings/llm_profiles.py:108), embedded in the Settings doc — a secondLLMProfilesclass, diverging from the SDK one. - Activation copies
profile.llmintoagent_settings.llm;reconcile_active_profile(settings_models.py:179) clears the active marker when the live LLM diverges — the dual-source-of-truth tax, made explicit.
Two parallel mid-conversation pickers: SwitchProfileButton (native LLM profiles) vs ChatInputModel (ACP model within the bound provider). They want to be one.
No conversation → profile provenance. AppConversationInfo (app_conversation/app_conversation_models.py:106) stores only llm_model, agent_kind, and a tags bag. Nothing records which profile (or what effective settings) a conversation launched with — so a runtime-compatibility check has nothing authoritative to compare against.
3. The core decision: embed config, reference only secrets
This is where I diverge from the prior drafts, so I'll make the case directly.
There are two ways to get "reusable agent setups":
(A) Reference composition — AgentProfile holds llm_profile_ref → LLMProfile and mcp_profile_ref → a new MCPProfile. Edit the shared ingredient once, every profile updates.
(B) Value composition — AgentProfile embeds its full config (an AgentSettingsConfig), and the only thing it references is secrets (which already live in a name-addressed secrets store).
I recommend (B), and recommend against making (A) the foundation. Reasoning:
-
(A) imports a foreign-key integrity problem into a per-user JSON store with no relational guarantees. It forces restrict-on-delete (409s when a profile is referenced), cascade-on-rename, and resolve-time validation for dangling refs — and forces every backend (local file store, app-server JSON, SaaS org/user columns) to re-implement those FK semantics identically. That is a large, perpetual bug surface for a feature whose entire selling point is simplicity. Tellingly, in the reference design that machinery is both the biggest section and the top-listed risk.
-
The thing that genuinely needs single-source-of-truth is credentials, and those are already referenced. What actually rotates and benefits from "edit once" is the API key / endpoint — and ACP creds already live in the secrets store keyed by
api_key_env_var, and LLM keys are heading the same way (Simplify LLM settings around profiles and remove raw LLM config from settings surfaces #3511). The model choice is precisely what distinguishes one profile from another ("Opus for hard tasks" vs "cheap GPT") — you do not want that shared. So the reusable part of an "LLM profile" is mostly the credential, which is the secrets store's job. Reference secrets; embed the rest. -
(B) maps 1:1 onto what the SDK already has. A profile is an
AgentSettingsConfig(which already embedsllm+mcp_config+agent_context). Resolution isprofile.agent_settings+ secret hydration — not a multi-store join. The execution path (create_agent,apply_agent_settings_diff, schema export, provider registry) is completely unchanged, with less new machinery than (A), not more. -
(B) makes profiles atomic, portable, and secret-free at rest. A profile exports/imports/shares as one JSON blob (great for org-standard setups and for support). Because secrets are referenced, sharing a profile never leaks a key. Delete/rename anything freely — there is no referential integrity to violate.
-
Conversation provenance falls out for free. Stamping a value snapshot of the profile onto the conversation is trivial and unambiguous; with references you'd have to snapshot-resolve anyway to answer "did the running config change?" — so you end up with values at the point that matters regardless.
What about MCP-set reuse? It's the one place (A) has a real ergonomic point — re-entering 5 MCP servers across profiles is annoying. My answer for v1: embed mcp_config in the profile and lean on "Duplicate profile" for reuse; MCP secrets are already referenced so nothing leaks. If, and only if, real usage shows people maintaining the same large MCP set across many profiles, add a named MCP set as an optional referenced sub-resource later — as an optimization layer on top of value-profiles, not as the foundational integrity model. YAGNI on the FK graph until proven.
If we later decide reuse is worth the lifecycle cost, (B) → (A) is an additive change (a profile field "inherit LLM/MCP from "). (A) → (B) is not. Starting at (B) keeps the option open at lower risk.
4. The model
A thin authoring/storage wrapper around the SDK union. Define once in the SDK so the file store, agent-server, app-server, and ts-client all share it.
# openhands-sdk/openhands/sdk/profiles/model.py (new)
class ProfileLaunchDefaults(BaseModel):
"""Launch-time conversation defaults a profile suggests (overridable per
conversation). These live in ConversationSettings in the SDK, not
AgentSettings, so they need a home on the profile."""
max_iterations: int | None = None
confirmation_mode: bool | None = None
security_analyzer: str | None = None
class AgentProfile(BaseModel):
id: str # uuid; stable across rename
name: str # editable, user-facing
revision: int = 1 # bumped on save; cheap staleness hint
agent_settings: AgentSettingsConfig # THE union — agent_kind lives here
launch_defaults: ProfileLaunchDefaults = Field(default_factory=ProfileLaunchDefaults)
# kind is derived: agent_settings.agent_kind (never duplicated)agent_settingsis the real SDK union → inherits its validators, secret masking, schema export, andapply_agent_settings_diff.condenser/verificationcome for free (they're already onOpenHandsAgentSettings); ACP variant hides them via the existing section variants.- Skills =
agent_context.skills+system_message_suffix(OpenHands only; the suffix is the v1 "system-prompt override" — a full override is a separate, larger change). ACP has no skills concept (the CLI owns its context) — explicitly out of scope, not faked. - Programmatic fields (
acp_isolate_data_dir,acp_file_secrets,agent_context.secrets) are not user profile data; they default and are injected by the deploying app at conversation start. - Secrets are referenced, not stored on the profile. OpenHands
llm.api_keymay stay embedded-and-encrypted for local/BYOR continuity in v1, but the direction is to reference it from the secrets store; ACP provider creds are always referenced (keyed byapi_key_env_var+ file-secrets), derivable fromacp_servervia the registry. A profile declares which secrets it needs; the secret values resolve per-user at launch.
MCPProfile and llm_profile_ref are intentionally not introduced (see §3).
5. Single source of truth
Today there's a global agent_settings and a profiles dict, reconciled by hand. Collapse to: the set of profiles + an active_profile_id pointer. The "current configuration" is the active profile.
- Editing in Settings → Agents edits the active profile (explicit Save / Save as new); an unsaved edit is a working draft over the active profile, not a mutation of a separate global.
Settings.agent_settingsbecomes a materialized view of the active profile for legacy readers (conversation start,llm_api_key_is_set, the per-section settings pages), kept populated during a transition, then retired. This deletesreconcile_active_profileand the dual-source dance, and realizes Simplify LLM settings around profiles and remove raw LLM config from settings surfaces #3511 generalized from LLM → whole agent.- All diff application delegates to the SDK
apply_agent_settings_diff— retiring the three hand-rolledagent_kindnarrowers (SDK /Settings.update/OrgStore._merge_and_validate_settings).
6. Runtime switching — one capability planner
Mid-conversation switching is a pure function of (conversation snapshot, target profile, provider registry), exposed identically in Python and TS, and unit-tested in isolation:
deriveSwitchPlan(snapshot, profile, registry) ->
| { action: "current" }
| { action: "switch-live"; mutableFields } // apply now, keep context
| { action: "start-new"; reason } // valid, needs a fresh conversation
| { action: "disabled"; reason } // not offerable
| From → To | Live? | Mechanism | Else |
|---|---|---|---|
OpenHands → OpenHands, only llm differs (model/base_url/key) |
✅ | re-point LLM → in-sandbox SwitchLLMTool |
— |
| OpenHands → OpenHands, MCP / tools / condenser / verification / skills differ | ❌ | — | start-new (reason: "MCP differs", …) |
ACP → ACP, same provider + launch identity, only acp_model differs, supports_runtime_model_switch |
✅ | session/set_model |
— |
| ACP → ACP, different provider / command / creds | ❌ | — | start-new |
| OpenHands ↔ ACP (kind change) | ❌ never | — | start-new (one-way narrowing gate) |
start-newis a first-class action, not a dead greyed row — "New conversation with this profile." Better UX than pure disable.- "Switch only the LLM" (the explicit ask) is row 1: re-point the conversation's effective LLM to another profile's LLM. You cannot "switch the LLM but keep the old MCP" from a different profile silently, because the target profile's MCP would then be a lie about what's running — that's exactly the case the planner routes to
start-new. - agent_kind is fixed per profile (chosen at creation, never flips in place — mirrors
apply_agent_settings_diffand the prod-500 lesson of OpenHands#14674). Converting = make a new profile of the other kind.
7. Conversation provenance
Stamp the launching profile onto the conversation record (today only agent_kind + tags exist):
class LaunchedProfile(BaseModel):
profile_id: str | None
profile_revision: int | None
agent_settings: dict # normalized, secret-free fingerprint
launch_defaults: dictactive_profile_id on PersistedSettings is the default for new conversations; each conversation records its own LaunchedProfile. The planner compares a candidate profile against this snapshot (authoritative even after the profile is later edited). This is #669's ConversationProfileSnapshot, anchored to the SDK's own normalized dump rather than a hand-listed field set.
8. UX (agent-canvas)
Settings → Agents = the profile library + editor, which cleanly dissolves the current "is this an ACP backend" global nav-lockout: there is no global ACP mode — each profile is OpenHands or ACP and the editor shows the right sections per kind (driven by the existing variant-tagged schema).
- Library (
/settings/agents): cards with a kind badge (OpenHands / Claude Code / Codex / Gemini), the model, the MCP server count, an Active badge, and Edit / Duplicate / Set active / Rename / Delete. - Editor — kind-aware: OpenHands → LLM (model + credential) / system-prompt suffix / condenser / verification / sub-agents / parallel tools / MCP servers / skills; ACP → provider /
acp_model(fromprovider.available_models) / credential section / advanced (command / args / session-mode / timeout) / MCP servers. MCP is edited inline (reusing the existingmcp-server-form), not as a separate referenced entity. - One unified chat-input picker replacing the
SwitchProfileButton/ChatInputModelbranch: lists agent profiles withderiveSwitchPlanapplied — live-switchable act immediately;start-newoffers a new conversation; incompatible are greyed with a reason chip. At creation, all profiles are selectable (capability filtering is mid-conversation only).
9. Migration & back-compat
- Existing LLM profiles preserved verbatim. On first load, auto-synthesize an
OpenHandsAgentProfileper existing LLM profile (agent_settings.llm= that LLM;mcp_config= the user's current singlemcp_config; skills = current global deny-list). The previously-active LLM profile becomes the active agent profile. A user who never opens the new UI sees identical behavior. - Legacy payloads (
agent_kindmissing /"llm") keep validating via the SDK's existingvalidate_agent_settingscanonicalization — no new execution-layer migration. - No FK graph to migrate (the value model has none).
10. Storage & API (local-first, cloud-ready)
Local (this milestone) — software-agent-sdk agent-server:
- One new
AgentProfileStore, file-backed under~/.openhands/agent-profiles/, modeled onLLMProfileStore(file lock, schema version, cipher, name pattern,list_summaries).LLMProfileStorestays as the referenced secret/LLM substrate; noMCPProfileStore. - New router
/api/agent-profiles(CRUD +/activate), mirroringprofiles_router.py.active_profile_id(generalizingactive_profile) onPersistedSettings. - A thin
resolve(profile, secret_store) -> AgentSettingsConfig(hydrate referenced secrets; everything else is already embedded) — a single small owner, no cross-store join, no dangling-ref class of errors. - Conversation start resolves the active/requested profile →
AgentSettingsConfigbefore the existingmodel_copy / create_agentstep; stampsLaunchedProfile.
Cloud (designed-for, next milestone) — OpenHands app_server + enterprise:
- Generalize
Settings.llm_profiles→agent_profiles(org + user columns mirror today's), same store contract as local so canvas calls one client interface (noif local / if cloud). Consolidate the three diff-appliers ontoapply_agent_settings_diffhere. - Because secrets are referenced (not embedded), the org/member overlay stays simple: a profile is a shareable, secret-free value; secrets resolve in the member's own scope. (Contrast: a referenced-MCP model would force a new org-vs-member resolution design for the reference name — another reason §3 picks value composition.)
11. Implementation plan (phased; each shippable)
Phase 0 — SDK model (software-agent-sdk): AgentProfile + ProfileLaunchDefaults wrapping AgentSettingsConfig; keep the LLM-profile API as a thin facade. No behavior change.
Phase 1 — SDK store + router: AgentProfileStore, /api/agent-profiles (CRUD + activate), active_profile_id on PersistedSettings, resolve() + secret hydration. Unit tests: resolution, kind-narrowing, secrets masked at rest, migration synthesis.
Phase 2 — conversation wiring: resolve active/requested profile → AgentSettingsConfig at start; stamp LaunchedProfile; generalize sandbox profile seeding.
Phase 3 — capability planner: pure deriveSwitchPlan() (Py + TS) over the provider registry; the matrix in §6.
Phase 4 — client types (typescript-client): AgentProfile + AgentProfilesClient; mirror registry capability flags.
Phase 5 — canvas UX (agent-canvas): Settings → Agents library + kind-aware editor (retires the ACP nav-lockout); one unified picker; migration shim.
Phase 6 — cloud (OpenHands): app_server + enterprise stores/routers behind the shared contract; retire the standalone global agent_settings once readers migrate; consolidate diff-appliers.
Prior art & disposition
This supersedes the earlier "ACP agent profiles" direction (closed as superseded 2026-06-15): agent-canvas #669 / #840 / #769 / #928, software-agent-sdk #3433 / #3707, OpenHands #14454, typescript-client #195. The one genuinely reusable idea — a pure capability-switch planner — is lifted and rebuilt for this model (§6).
Depends on / aligned with (kept open): software-agent-sdk #3706 (adopt apply_agent_settings_diff everywhere) and #3705 (codify ACP MCP forwarding); #3511 (profiles as the single source of truth — this generalizes it from LLM to the whole agent).
Open questions
- Embedded-encrypted vs. referenced OpenHands
llm.api_keyfor v1. Recommend keep embedded-encrypted for BYOR/local continuity, reference-only for ACP; revisit once the secrets store is the universal path. - Skills move from a global deny-list to per-profile selection — net-better but a behavior change; migration seeds the current deny-list so day-one behavior is identical. Confirm we want per-profile skills.
- Retire the standalone global
agent_settingsafter readers migrate (Phase 6) — it's a real API-surface change; sequence behind the breakage gates. - Named MCP sets: ship inline-MCP for v1; only add an optional referenced MCP set later if real usage shows cross-profile MCP reuse. Agree to defer?
- One active profile (default for new conversations) + per-conversation stamp — confirm this matches the desired UX vs. a purely per-conversation model.
Activity