HKUDS/DeepTutor · error · HTTPException

Both name and agent_kind are required.

Error message

Both name and agent_kind are required.

What it means

Required-field guard at the top of POST /connections: name and agent_kind were both stripped and at least one is empty, so the connection cannot be created. The endpoint needs both to identify and route the subagent.

Solutions

  1. Fill both name and agent_kind with non-blank values
  2. Trim inputs client-side before POST
  3. Check the request payload actually serializes both fields

Example fix

// before
{"name": "  ", "agent_kind": "opencode"}
// after
{"name": "my-agent", "agent_kind": "opencode"}
Defensive patterns

Strategy: validation

Validate before calling

const name = rawName.trim();
const kind = rawKind.trim();
if (!name || !kind) return; // don't send
await fetch('/connections', {method:'POST', body: JSON.stringify({name, agent_kind: kind})});

Type guard

const isValidConnectionPayload = (p: any): p is {name:string; agent_kind:string} =>
  typeof p?.name === 'string' && p.name.trim() !== '' &&
  typeof p?.agent_kind === 'string' && p.agent_kind.trim() !== '';

Try / catch

try { await createConnection(p); } catch (e) { if (e.status === 400) showFormError(e.detail); }

Prevention

When it happens

Trigger: POST /connections with {"name":""}, {"agent_kind":" "}, or either field omitted/null.

Common situations: Frontend form submitted before user fills both fields; whitespace sneaking in from a trimmed-elsewhere input; payload built with undefined JS variables.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/0ac7214eeae46187. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/subagents.py:144

                "updated_at": meta.get("updated_at"),
            }
        )
    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

View on GitHub (pinned to 3e82f13042)