Skip to content

Seeded default AgentProfile permanently persists an orphaned, keyless 'default' LLM profile (gpt-5.5) #4031

Closed

Description

@simonrosenberg

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 to llm_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 via llm_store.save(SEED_PROFILE_NAME, llm, ...), using settings.agent_settings.llm (which on a fresh account is just LLM() 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 first GET /api/agent-profiles against an empty agent-profile store.

Repro

  1. Fresh account / fresh OH_PERSISTENCE_DIR (verified locally against openhands-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 to SaasSettingsStore's "legacy-LLM backfill").
  2. Load the app for the first time (or just hit GET /api/agent-profiles once) before configuring any LLM.
    • This silently creates ~/.openhands/profiles/default.json: a full dump of LLM() defaults — model: "gpt-5.5", no api_key — and seeds a default AgentProfile (agent_kind=openhands) with llm_profile_ref="default".
  3. Go through onboarding / Settings and create a real LLM profile (e.g. opus48 with a real model + key). The agent profile's llm_profile_ref is correctly repointed to opus48 (confirmed via revision bump 0 → 1).
  4. Open Settings → LLM Profiles: two profiles exist — the real one just created, and an unexplained default profile with model gpt-5.5 and 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_ref moves 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:

  1. 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/profiles unless a user actually saved it.
  2. If persisting is required for some architectural reason, garbage-collect the placeholder once no AgentProfile.llm_profile_ref points at SEED_PROFILE_NAME anymore (e.g., as part of the repoint that happens when a real profile is created/activated).
  3. 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's npm run dev local dev stack.
  • Also affects cloud (SaasSettingsStore), per this code's own docstring reference to the "legacy-LLM backfill" doing the same thing there.

Activity

  1. simonrosenberg commented on Jul 8, 2026

    @simonrosenberg
    MemberAuthor

    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 (useLlmConfigured in agent-canvas). That settles the "in what cases do we want to seed a bad LLM profile?" question precisely:

    1. The banner never needed the seeded placeholder. useLlmConfigured checks whether the referenced profile (activeAgentProfile.llm_profile_ref) has api_key_set or is a subscription config — not whether a profile named default exists at all. If llm_profile_ref="default" simply dangles (no file on disk), the hook already correctly reports isConfigured: false and surfaces the banner. Persisting the placeholder changes nothing about this UX.

    2. The diagnostics/materialize path already handles a dangling ref gracefully. resolve_agent_profile_dry_run (backing /materialize and the canvas editor) records dangling_llm_profile_ref instead of raising. Settings UX is unaffected either way.

    3. Only the real launch path raises — resolve_agent_profile inside conversation_service.start_conversation raises ProfileNotFound, which conversation_router.py:212 already converts to a legible HTTPException(404, "LLM profile 'default' not found"). Since canvas gates sending a message on isConfigured, 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.

    4. 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 whose agent_settings.llm already carries a real, working config (API key, or managed/subscription billing) from before AgentProfiles existed. Backfilling that into a named default LLM profile is the right migration behavior; it preserves an already-functioning setup.

    Proposed fix

    • Keep unconditional AgentProfile seeding as-is — cheap, harmless, gives the user something in Settings → Agent immediately.
    • In _seed_default_llm_profile (agent_profiles_router.py), only actually persist a default LLM profile when agent_settings.llm represents real, pre-existing configuration — gate on the same signal already used elsewhere in this file (_has_api_key(llm)) OR llm.is_subscription truthy OR a non-default base_url. If none hold, it's untouched SDK bare defaults from a never-configured account: skip persisting, leave llm_profile_ref="default" as a soft/dangling reference, and let the already-correct banner + already-legible launch-time error do their job.
    • Optional polish: recode the launch-time ProfileNotFound response from 404 to 422 with a structured detail, matching the DanglingMcpServerRef pattern immediately above it in conversation_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions