Repository navigation
Closed
Labels
Description
Summary
The #3933 fix for the dangling llm_profile_ref on a freshly-seeded default AgentProfile works by permanently persisting a placeholder LLM profile literally named default, built from bare SDK field defaults (model="gpt-5.5", no api_key). Once a user configures a real LLM profile, the agent profile's llm_profile_ref is correctly repointed away from it, but the placeholder is never cleaned up — it's left behind forever as a keyless, non-functional "ghost" profile in the LLM profiles list that the user never asked for.
Where
openhands/sdk/profiles/seed.py—build_seed_profile(): falls back tollm_profile_ref = SEED_PROFILE_NAME("default") when no LLM profile is active yet.openhands/agent_server/agent_profiles_router.py:127-177—_seed_default_llm_profile(): materializes that fallback into a real, persisted LLM profile viallm_store.save(SEED_PROFILE_NAME, llm, ...), usingsettings.agent_settings.llm(which on a fresh account is justLLM()with pure defaults:model="gpt-5.5",api_key=None).- Called from
_seed_default_profile()(same file, ~line 180-219), which runs lazily on the very firstGET /api/agent-profilesagainst an empty agent-profile store.
Repro
- Fresh account / fresh
OH_PERSISTENCE_DIR(verified locally againstopenhands-agent-server==1.33.0, but the code path is unconditional so this should reproduce on any recent release and on cloud too, per the docstring's own reference toSaasSettingsStore's "legacy-LLM backfill"). - Load the app for the first time (or just hit
GET /api/agent-profilesonce) before configuring any LLM.- This silently creates
~/.openhands/profiles/default.json: a full dump ofLLM()defaults —model: "gpt-5.5", noapi_key— and seeds a defaultAgentProfile(agent_kind=openhands) withllm_profile_ref="default".
- This silently creates
- Go through onboarding / Settings and create a real LLM profile (e.g.
opus48with a real model + key). The agent profile'sllm_profile_refis correctly repointed toopus48(confirmed via revision bump0 → 1). - Open Settings → LLM Profiles: two profiles exist — the real one just created, and an unexplained
defaultprofile with modelgpt-5.5and no API key, which was never explicitly created and cannot be used (no credentials, and nothing references it anymore).
Why this is a problem
- It's confusing: from the user's perspective, they never created this profile, yet it appears in the list and shows a real (if unfamiliar) model name — it isn't obviously a placeholder.
- It's non-functional: no API key is ever attached, so attempting to use it fails outright. A keyless, unusable default is worse than no profile at all.
- It's permanent: nothing garbage-collects it once the agent profile's
llm_profile_refmoves on to a real profile, so it lingers indefinitely as dead clutter in the profile list, on every fresh install/account forever.
Suggested fix
The underlying goal (avoid the #3933 dangling-ref 404 at launch) doesn't require persisting a real, listed profile. Options, roughly in order of preference:
- Make the fallback resolve in-memory only at materialize/launch time (i.e., in the resolver) rather than writing a file the moment the agent-profile store is first touched — nothing should show up in
GET /api/profilesunless a user actually saved it. - If persisting is required for some architectural reason, garbage-collect the placeholder once no
AgentProfile.llm_profile_refpoints atSEED_PROFILE_NAMEanymore (e.g., as part of the repoint that happens when a real profile is created/activated). - At minimum, mark the seeded placeholder so the UI (canvas Settings → LLM Profiles) can filter/label it distinctly instead of listing it as an indistinguishable, real user profile.
Environment
openhands-agent-server==1.33.0(PyPI), reproduced via agent-canvas'snpm run devlocal dev stack.- Also affects cloud (
SaasSettingsStore), per this code's own docstring reference to the "legacy-LLM backfill" doing the same thing there.
Activity
simonrosenberg commentedon Jul 8, 2026
Refined recommendation
Compared against
main(identical behavior — not something already fixed upstream) and traced how the canvas "LLM not set up" banner actually decides its state (useLlmConfiguredin agent-canvas). That settles the "in what cases do we want to seed a bad LLM profile?" question precisely:The banner never needed the seeded placeholder.
useLlmConfiguredchecks whether the referenced profile (activeAgentProfile.llm_profile_ref) hasapi_key_setor is a subscription config — not whether a profile nameddefaultexists at all. Ifllm_profile_ref="default"simply dangles (no file on disk), the hook already correctly reportsisConfigured: falseand surfaces the banner. Persisting the placeholder changes nothing about this UX.The diagnostics/materialize path already handles a dangling ref gracefully.
resolve_agent_profile_dry_run(backing/materializeand the canvas editor) recordsdangling_llm_profile_refinstead of raising. Settings UX is unaffected either way.Only the real launch path raises —
resolve_agent_profileinsideconversation_service.start_conversationraisesProfileNotFound, whichconversation_router.py:212already converts to a legibleHTTPException(404, "LLM profile 'default' not found"). Since canvas gates sending a message onisConfigured, a UI user should never actually hit this — it mainly protects direct API / automation callers that bypass the UI gate, and that case already gets a clear (if perhaps mis-coded, see below) error today.So for a fresh, never-configured account, eagerly materializing a keyless
LLM()-defaults profile (model=gpt-5.5, no key) buys nothing beyond what's already covered by (1)-(3) — it only adds a permanent, confusing, non-functional entry to the LLM profiles list.Where seeding a real profile is correct: per this code's own docstring, it "mirrors
SaasSettingsStore's legacy-LLM backfill" — an existing account/org whoseagent_settings.llmalready carries a real, working config (API key, or managed/subscription billing) from before AgentProfiles existed. Backfilling that into a nameddefaultLLM profile is the right migration behavior; it preserves an already-functioning setup.Proposed fix
AgentProfileseeding as-is — cheap, harmless, gives the user something in Settings → Agent immediately._seed_default_llm_profile(agent_profiles_router.py), only actually persist adefaultLLM profile whenagent_settings.llmrepresents real, pre-existing configuration — gate on the same signal already used elsewhere in this file (_has_api_key(llm)) ORllm.is_subscriptiontruthy OR a non-defaultbase_url. If none hold, it's untouched SDK bare defaults from a never-configured account: skip persisting, leavellm_profile_ref="default"as a soft/dangling reference, and let the already-correct banner + already-legible launch-time error do their job.ProfileNotFoundresponse from 404 to 422 with a structured detail, matching theDanglingMcpServerRefpattern immediately above it inconversation_router.py— a nice-to-have for API callers, not required to fix the core complaint.This is safer than unconditionally never seeding: it fixes the ghost-profile problem for every new account while preserving the real cloud/legacy-account migration case the mechanism was actually built for.
fix(agent-profiles): only seed a 'default' LLM profile for real config (