Repository navigation
Description
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Is there an existing issue for the same bug?
- I have searched existing issues and this is not a duplicate.
Bug Description
The LLM-profile store treats foo and foo.json as the same profile (GET /api/profiles/foo.json reads foo), but the agent-profile FK guard and the active_profile pointer compare the raw name. So DELETE /api/profiles/qa-alias.json answers 200 and deletes qa-alias while an agent profile still cites it through llm_profile_ref, although DELETE /api/profiles/qa-alias correctly answers 409. The same mismatch leaves active_profile naming a deleted profile after an alias delete, and an alias rename (POST /api/profiles/qa-alias.json/rename) moves the file without moving active_profile or the agent profiles' llm_profile_ref.
Expected Behavior
DELETE /api/profiles/qa-alias.json answers 409 with LLM profile is referenced by 1 agent profile(s): qa-f20-alias-agent, like the plain name, and qa-alias survives. Deleting or renaming through the alias clears / moves active_profile and cascades llm_profile_ref exactly as the plain name does.
Actual Behavior
200 {"name": "qa-alias.json", "message": "Profile 'qa-alias.json' deleted"}; afterwards GET /api/profiles/qa-alias is 404 Profile 'qa-alias' not found while qa-f20-alias-agent still has llm_profile_ref: "qa-alias".
Steps to Reproduce
- In a checkout of main:
uv sync, thenSESSION_API_KEY=dev-key uv run python -m openhands.agent_server --host 127.0.0.1 --port 8000. - With
H='X-Session-API-Key: dev-key'andB=http://127.0.0.1:8000/api:
curl -s -H "$H" -H 'Content-Type: application/json' -X POST $B/profiles/qa-alias -d '{"llm": {"model": "openai/qa-alias"}}'
curl -s -H "$H" -H 'Content-Type: application/json' -X POST $B/agent-profiles/qa-f20-alias-agent -d '{"llm_profile_ref": "qa-alias"}'
curl -s -H "$H" -X DELETE $B/profiles/qa-alias # 409, referenced by qa-f20-alias-agent (control)
curl -s -H "$H" -X DELETE $B/profiles/qa-alias.json # 200 "Profile 'qa-alias.json' deleted"
curl -s -H "$H" $B/profiles/qa-alias # 404With the verify-agent-server skill (#5621): control-agent-server map run --file F20 --only F20.json-alias-guard --fresh reports the known-bug bullet as an expected failure while the bug lasts.
Acceptance Criteria
-
DELETE /api/profiles/<name>.jsonanswers409naming the referrers wheneverDELETE /api/profiles/<name>would, and the profile survives. - Deleting through the alias clears
active_profilewhen it names that profile; renaming through the alias movesactive_profileand cascadesllm_profile_reflike the plain name. - A unit test covers the alias in the FK guard (
openhands-sdk/openhands/sdk/profiles/profile_refs.py) and the router. - The map bullet
F20.json-alias-guardpasses with its# bugmarker removed.
Installation Method
uv sync in a checkout of main
Version
main at 6e7a853
Additional Context
Root cause:
LLMProfileStore._get_profile_pathstrips a trailing.json(openhands-sdk/openhands/sdk/llm/llm_profile_store.py:166), soqa-alias.jsonaddresses the fileqa-alias.jsonof profileqa-alias._scan_referrerscomparesllm_profile_refwith the raw name (openhands-sdk/openhands/sdk/profiles/profile_refs.py:66); it is used bydelete_llm_profileand by the rename cascade (_rewrite_refs)._set_active_profile_if_matchescomparesactive_profilewith the raw name (openhands-agent-server/openhands/agent_server/profiles_router.py:136), called from delete and rename.
Related: the agent-profile store has the same suffix mismatch for its own identity (map ID F21.json-suffix-identity), which is a separate fix.
Found by the first full agentic run of verify-agent-server; tracked in #5653.
Activity
enyst commentedon Oct 14, 2026
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
A fix is on branch
claude/umbrella-bug-fixes-tgz9ai-json-alias-guard(PR follows). It addscanonical_profile_name()next to_get_profile_pathinllm_profile_store.py. The FK scan and rename cascade inprofile_refs.pyand theactive_profilepointer inprofiles_router.py(delete, rename, activate) now compare and store that key. Sofoo.jsonacts exactly likefoo, andactive_profile/llm_profile_refalways record the plain name.Decision needed (maintainer): I kept the
.jsonalias and made every path honour it. Two things follow from that choice:profile_refs.pyis meant to work with any store, and it now applies the file store's rule (foo.jsonisfoo) whatever LLM store sits behind it. The regex accepts names likefoo.json, so a non-file store that treats them as separate profiles would also see the guard treat them as one. No such store exists in this repo today..jsonwith 422 at the API (and in_get_profile_path), so the alias does not exist at all. That is a stricter API change: existingGET /api/profiles/foo.jsoncalls would start failing. The F21 sibling (F21.json-suffix-identity) lists the same 422 option for agent profiles, so the two stores could be made to match later either way.Generated by Claude Code