HKUDS/DeepTutor · error · HTTPException
Unknown agent kind: {agent_kind!r}
Error message
Unknown agent kind: {agent_kind!r} What it means
create_connection rejects agent_kind values not present in list_backend_kinds(); the kind must match a registered subagent backend exactly (case-sensitive).
Source
Thrown at deeptutor/api/routers/subagents.py:146
)
return {"connections": connections}
@router.post("/connections")
async def create_connection(payload: ConnectSubagentRequest):
"""Connect a subagent (a local CLI, or one of the user's partners) as a selectable KB.
A partner connection (``agent_kind == "partner"``) binds a ``partner_id``
instead of a working directory: consulting it opens a fresh session on that
partner, exactly as if the user started one from the partner page. Every
consult within one DeepTutor chat lands in that one partner session.
"""
name = (payload.name or "").strip()
agent_kind = (payload.agent_kind or "").strip()
if not name or not agent_kind:
raise HTTPException(status_code=400, detail="Both name and agent_kind are required.")
if agent_kind not in list_backend_kinds():
raise HTTPException(status_code=400, detail=f"Unknown agent kind: {agent_kind!r}")
resolved_cwd = ""
partner_id = ""
if agent_kind == PARTNER_BACKEND_KIND:
partner_id = (payload.partner_id or "").strip()
if not partner_id:
raise HTTPException(
status_code=400, detail="A partner_id is required to connect a partner."
)
# Partners are admin-managed, but an admin can assign one to a user via
# the grant system. An admin may connect any partner; a non-admin only a
# partner assigned to them (403 otherwise). The partner still runs in its
# own isolated scope — connecting just lets the user consult it in chat.
assert_partner_allowed(partner_id)
from deeptutor.services.partners import get_partner_manager
if not get_partner_manager().partner_exists(partner_id):
raise HTTPException(status_code=400, detail=f"No partner named {partner_id!r}.")View on GitHub (pinned to 3e82f13042)
Solutions
- Fetch the backend kinds list endpoint and use one of its exact values
- Correct casing/spelling of the kind
- Update DeepTutor so the expected backend is registered
Example fix
// before
{"agent_kind": "codex"}
// after
{"agent_kind": "openai-codex"} // exact value from list_backend_kinds() Defensive patterns
Strategy: validation
Validate before calling
const kinds = await listBackendKinds();
if (!kinds.includes(agentKind)) { agentKind = kinds[0]; } // or block submit Type guard
const isKnownKind = (k: string, known: string[]) => known.includes(k);
Try / catch
try { await createConnection(payload); } catch (e) { if (e.status === 400 && /Unknown agent kind/.test(e.detail)) refreshKinds(); } Prevention
- Never hardcode kind strings; derive from the API
- Handle renames by refetching kinds on 400
When it happens
Trigger: POST /connections with an agent_kind like "Claude" vs "claude-code", or a backend kind removed in a newer version.
Common situations: Version drift after backends are renamed; hand-written kind strings; stale frontend options list.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown agent kind: {kind!r}
- Both name and agent_kind are required.
- A partner_id is required to connect a partner.
- No partner named {partner_id!r}.
- {exc}
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/0098de1a2da36f54.
Report an issue: GitHub.