Repository navigation
Description
I'm an AI agent based on Opus 5.5, 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
A file-based sub-agent whose frontmatter skills names a skill that does not exist breaks every conversation that loads it. POST /api/sub-agents lists the agent as valid, but the conversation's first message returns 500, and so does every later one. The same file in ~/.agents/agents breaks new conversations in every workspace on the server.
Expected Behavior
Only that sub-agent is lost: it is skipped with a warning naming the file and the missing skill (as invalid frontmatter already is), and the message is accepted (200). A 4xx naming the agent and skill would also do. POST /api/conversations with initial_message does not return 500.
Actual Behavior
POST /api/conversations/{id}/eventsreturns 500, loggingValueError: Skill 'qa-f27-missing-skill' not found but was given to agent 'qa-bad-skill'.Later messages fail the same way.- With
initial_message,POST /api/conversationsreturns 500, yet the conversation is stored and listed asidle. POST /api/sub-agentsfor thatproject_dirreturns 200 and listsqa-bad-skillwithout a warning.
Steps to Reproduce
- Start a server from a checkout:
uv run python -m openhands.agent_server --port 8000. - Create a workspace with the agent file:
W=$(mktemp -d); mkdir -p "$W/.agents/agents" printf -- '---\nname: qa-bad-skill\ndescription: Bad skill\nskills: qa-f27-missing-skill\n---\nBody\n' > "$W/.agents/agents/qa-bad-skill.md" - Create a conversation there and send a message (
run: false, so no model call):PrintsCID=$(curl -s localhost:8000/api/conversations -H 'content-type: application/json' \ -d '{"agent": {"kind": "Agent", "llm": {"model": "test"}, "tools": []}, "workspace": {"working_dir": "'"$W"'"}}' | jq -r .id) curl -s -o /dev/null -w '%{http_code}\n' localhost:8000/api/conversations/$CID/events -H 'content-type: application/json' \ -d '{"role": "user", "content": [{"type": "text", "text": "hi"}], "run": false}'500; a workspace without.agents/agentsgives200. - Repeat the create with
"initial_message": {"role": "user", "content": [{"type": "text", "text": "hi"}]}: it returns 500, andGET /api/conversations/searchlists the conversation asidle.
With the verify-agent-server skill (#5621): control-agent-server map run --file F27 --only F27.subagents-bad-skill --fresh reports the known-bug bullet as an expected failure while the bug lasts.
Acceptance Criteria
- An agent file naming a missing skill no longer makes the message
POST, or a create withinitial_message, return 500. - The bad agent is skipped with a warning naming its file and skill (or the request is a 4xx naming them); other valid agents are still registered.
- A unit test covers
register_file_agentswith a definition naming a missing skill. - The map bullet
F27.subagents-bad-skillpasses and its# bugmarker is removed.
Installation Method
uv sync in a checkout of main
Version
main at 2804c12
Additional Context
LocalConversation.send_messageinitializes the agent on the first message (openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py:1822-1823);_ensure_agent_ready(:1569) reachesregister_file_agents(self.workspace.working_dir)(:1533).register_file_agents(openhands-sdk/openhands/sdk/subagent/registry.py:288-333) builds a factory for every project and user definition (:319-320) without error handling, andagent_definition_to_factoryraisesValueErrorfor an unknown skill (:198-203).event_router.py:227does not catch it, so the route answers 500._agent_readyis set only at the end (local_conversation.py:1598), so each later message fails again.conversation_service.pystores the conversation (:1663) before sending the initial message (:1671), hence the leftoveridleconversation.- The catalog (
sub_agents_router.py:117-140) validates frontmatter only; the loader skips invalid files with a warning (subagent/load.py:213-220).
Suggested fix: in register_file_agents, catch the error per definition, log a warning with the agent name, its source and the message, and continue. register_plugin_agents (registry.py:356-357) has the same pattern.
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Confirmed bug in this repository (SDK + Agent Server). register_file_agents (openhands-sdk/openhands/sdk/subagent/registry.py) builds a factory for every deduplicated definition without per-definition error handling, and agent_definition_to_factory raises ValueError for an unknown skill (skills in frontmatter). That error escapes LocalConversation._ensure_agent_ready and the message route answers 500; _agent_ready is only set at the end, so later messages fail too, and a create with initial_message stores the conversation before it fails, leaving an idle conversation. The catalog endpoint (POST /api/sub-agents) validates frontmatter only, so it lists the agent without a warning — that is a separate, expected gap, not the defect.
Scope: make per-definition registration resilient for file-based agents so an individual bad definition is skipped with a warning naming the file/source and the offending skill, while other valid agents still register and the request succeeds. Apply the same treatment to register_plugin_agents, which shares the pattern.
Non-goals: changing POST /api/sub-agents catalog validation or adding a new 4xx API contract (a 4xx is an acceptable alternative for the fix, not a required deliverable); changing skill-resolution semantics; conversation create/rollback ordering beyond the secondary initial_message symptom; requiring the verify-agent-server map bullet (F27), which lives on the unmerged PR #5621 and is not on main.
Acceptance Criteria
- With a workspace whose
.agents/agents/contains a definition naming a nonexistent skill,POST /api/conversations/{id}/eventswithrun: falsereturns 200, and subsequent messages on the same conversation also return 200. (A 4xx naming the agent and skill is also acceptable for the first request.) -
POST /api/conversationswithinitial_messagein that workspace does not return 500 and does not leave a conversation stored asidlesolely because of the skill error. - The offending definition is not registered, and a warning is logged that names its file/
sourceand the missing skill; other valid agents in the same directory and in other scanned directories are still registered and usable. - The same resilience covers a plugin-provided definition naming a missing skill (
register_plugin_agents). - A definition naming a registered skill still resolves and registers unchanged (no regression to valid skill resolution).
- A unit test under
tests/sdk/subagent/exercisesregister_file_agentswith a definition naming a missing skill and asserts the bad agent is absent from the registry while valid agents are present. - If the non-fatal contract for registration is treated as an invariant,
openhands-sdk/openhands/sdk/subagent/AGENTS.md(and the linked user docs) state that a definition failing registration — e.g. naming an unknown skill — is skipped with a warning while other agents register. - Validation: the reproduction steps in the issue return 200 on the fixed revision (a live run against a checkout, or the
F27.subagents-bad-skillmap bullet once PR Add verify-agent-server: an executable feature map and control CLI for the Agent Server API #5621 lands).
Activity
enyst commentedon Oct 13, 2026
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
PR #5754 addresses this issue. Below, each point of the triage block in the issue body is answered (there were no separate comments).
Acceptance criteria
POSTwithrun: falsereturns 200, later messages too: done. The bad definition is skipped, so_ensure_agent_readycompletes. In a live run, both messages returned 200; on main the first one returned 500.initial_messagecreate does not return 500 or leave anidleconversation: done. The create returned 500 on main and 201 on the branch. Nothing fails after the conversation is stored, so no conversation is left behind.sourceand the skill, other agents still register: done. The warning readsSkipping file-based agent 'qa-bad-skill' from <path>: Skill 'qa-f27-missing-skill' not found but was given to agent 'qa-bad-skill'.A test registers a valid agent with a real skill next to the bad one and checks that the valid one resolves.register_plugin_agents): done. Both functions now go through one helper,_register_definition, and a separate test covers the plugin case.agent_definition_to_factoryskill tests still pass. Only the caller catches theValueError.tests/sdk/subagent/: two tests were added intest_subagent_registry.py. They fail on main and pass on the PR.subagent/AGENTS.md: done ("Registration failures must be non-fatal"). The user docs in OpenHands/docs are not updated in this PR.F27.subagents-bad-skillmap bullet exists on main. It reportedxfailtwice on main (dfd8fe8) andxpasstwice on the PR. The PR removes its# bugmarker, and the bullet now passes.Non-goals respected: the
POST /api/sub-agentscatalog still validates only frontmatter. The skip was chosen over a 4xx, which the issue accepts. Skill resolution and create ordering are unchanged.Maintainer decision needed: how this issue relates to #5718. The triage comment on #5718 asks whether #5718 absorbs this issue or stays a separate umbrella.
LocalConversation._ensure_plugins_loaded) and reporting load failures to the client stay with [Bug]: Plugin or skill loading error should not prevent conversation from starting #5718.clients/typescriptand the UI.Generated by Claude Code
enyst commentedon Oct 13, 2026
Agreed, this isn't much of a choice TBH since nobody doubted it. 😅