{"record":{"id":"0098de1a2da36f54","repo":"HKUDS/DeepTutor","slug":"unknown-agent-kind-agent-kind-r","errorCode":null,"errorMessage":"Unknown agent kind: {agent_kind!r}","messagePattern":"Unknown agent kind: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"deeptutor/api/routers/subagents.py","lineNumber":146,"sourceCode":"        )\n    return {\"connections\": connections}\n\n\n@router.post(\"/connections\")\nasync def create_connection(payload: ConnectSubagentRequest):\n    \"\"\"Connect a subagent (a local CLI, or one of the user's partners) as a selectable KB.\n\n    A partner connection (``agent_kind == \"partner\"``) binds a ``partner_id``\n    instead of a working directory: consulting it opens a fresh session on that\n    partner, exactly as if the user started one from the partner page. Every\n    consult within one DeepTutor chat lands in that one partner session.\n    \"\"\"\n    name = (payload.name or \"\").strip()\n    agent_kind = (payload.agent_kind or \"\").strip()\n    if not name or not agent_kind:\n        raise HTTPException(status_code=400, detail=\"Both name and agent_kind are required.\")\n    if agent_kind not in list_backend_kinds():\n        raise HTTPException(status_code=400, detail=f\"Unknown agent kind: {agent_kind!r}\")\n\n    resolved_cwd = \"\"\n    partner_id = \"\"\n    if agent_kind == PARTNER_BACKEND_KIND:\n        partner_id = (payload.partner_id or \"\").strip()\n        if not partner_id:\n            raise HTTPException(\n                status_code=400, detail=\"A partner_id is required to connect a partner.\"\n            )\n        # Partners are admin-managed, but an admin can assign one to a user via\n        # the grant system. An admin may connect any partner; a non-admin only a\n        # partner assigned to them (403 otherwise). The partner still runs in its\n        # own isolated scope — connecting just lets the user consult it in chat.\n        assert_partner_allowed(partner_id)\n        from deeptutor.services.partners import get_partner_manager\n\n        if not get_partner_manager().partner_exists(partner_id):\n            raise HTTPException(status_code=400, detail=f\"No partner named {partner_id!r}.\")","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/subagents.py#L128-L164","documentation":"create_connection rejects agent_kind values not present in list_backend_kinds(); the kind must match a registered subagent backend exactly (case-sensitive).","triggerScenarios":"POST /connections with an agent_kind like \"Claude\" vs \"claude-code\", or a backend kind removed in a newer version.","commonSituations":"Version drift after backends are renamed; hand-written kind strings; stale frontend options list.","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"],"exampleFix":"// before\n{\"agent_kind\": \"codex\"}\n// after\n{\"agent_kind\": \"openai-codex\"}  // exact value from list_backend_kinds()","handlingStrategy":"validation","validationCode":"const kinds = await listBackendKinds();\nif (!kinds.includes(agentKind)) { agentKind = kinds[0]; } // or block submit","typeGuard":"const isKnownKind = (k: string, known: string[]) => known.includes(k);","tryCatchPattern":"try { await createConnection(payload); } catch (e) { if (e.status === 400 && /Unknown agent kind/.test(e.detail)) refreshKinds(); }","preventionTips":["Never hardcode kind strings; derive from the API","Handle renames by refetching kinds on 400"],"tags":["http-400","subagent","backend-registry","api"],"backgroundTag":"invalid-enum-value","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}