Skip to content

[AgentProfile][sdk] AgentProfileStore + FK lifecycle (restrict-on-delete, cascade-rename, referrer scan) #3716

Closed

Description

@simonrosenberg

✅ As merged on main — DONE (PR #3775 · released in SDK v1.29.0)

  • AgentProfileStore — openhands-sdk/openhands/sdk/profiles/agent_profile_store.py: mirrors LLMProfileStore (save/load/delete/rename/list/list_summaries + name_for_id), filelock, atomic temp-file + Path.replace, PROFILE_NAME_PATTERN, max_profiles cap, cipher. save() encrypts skills[].mcp_tools (context expose_secrets="encrypted") and redacts otherwise; reference fields dump in clear. rename() is a surgical raw-JSON name edit preserving id. list_summaries() projects {id, name, agent_kind, revision, llm_profile_ref, mcp_server_refs} without instantiating secrets (llm_profile_ref forced None for ACP).
  • FK module — openhands-sdk/openhands/sdk/profiles/profile_refs.py: find_referrers, cascade_rename, ProfileReferenced(referrers) (routers map → 409), guarded delete_llm_profile / rename_llm_profile. Lock order agent-profiles → llm-profiles, held across check+mutate; FileLock is re-entrant within a thread (deadlock-safe). FK covers llm_profile_ref only — mcp_server_refs has no save-time FK (resolve-time only, [AgentProfile][sdk] resolve_agent_profile(): collision-checked composition + resource-specific secret channels #3717).

Note: the symmetric Skill.mcp_tools decrypt-on-load is a deferred follow-up — encrypted mcp_tools load back as ciphertext and are decrypted by the resolver (#3717), which holds the cipher. All acceptance criteria below are met.

Original spec (delivered as above)

Phase 1 — SDK substrate · software-agent-sdk · size M · Parent epic #3713

Depends on: [sdk] AgentProfile union models (#3715)

Context

Reference composition needs a real FK lifecycle so llm_profile_ref never silently dangles. This logic lives in the store/SDK layer (not routers) because it must hold the AgentProfileStore file lock while scanning + rewriting refs. mcp_server_refs values are names in the user's mutable global mcp_config — they are checked at resolve-time only, not FK-constrained here (a save-time FK would be a TOCTOU anyway since the user's mcp_config is editable independently).

Scope

  • AgentProfileStore mirroring LLMProfileStore under ~/.openhands/agent-profiles (filename = name; id stored inside the file), with save/load/delete/rename/list_summaries and cipher. list_summaries projects {id, name, agent_kind, revision, llm_profile_ref, mcp_server_refs} without loading secrets.
  • New FK module (e.g. openhands-sdk/openhands/sdk/profiles/profile_refs.py):
    • find_referrers(llm_profile_name) — scan AgentProfileStore for AgentProfiles citing a given LLM profile name.
    • cascade_rename(old_name, new_name) — rewrite all matching llm_profile_ref values atomically under the AgentProfileStore lock.
    • ProfileReferenced(referrers) exception (routers map → 409).
  • Cross-store lock ordering: profiles are HOME-rooted (~/.openhands/*) while PersistedSettings is workspace-rooted; document the lock acquisition order (agent-profiles, then llm-profiles) to avoid TOCTOU between "check referrers" and "delete".

Acceptance criteria

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions