{"record":{"id":"268f49b4aea0a8c6","repo":"langchain-ai/deepagents","slug":"task-requires-non-empty-string-field-subagentty","errorCode":null,"errorMessage":"task() requires non-empty string field `subagentType`","messagePattern":"task\\(\\) requires non-empty string field `subagentType`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/partners/quickjs/langchain_quickjs/_repl.py","lineNumber":553,"sourceCode":"    @staticmethod\n    def _validate_task_payload(\n        payload: dict[str, Any],\n    ) -> tuple[str, str, str | None, dict[str, Any] | None]:\n        \"\"\"Validate JS `task()` input and return its typed fields.\n\n        JS callers pass camelCase keys (`subagentType`, `responseSchema`) as\n        documented in the system prompt; the returned tuple is snake_case for\n        the Python dispatch path.\n        \"\"\"\n        description = payload.get(\"description\")\n        if not isinstance(description, str) or not description:\n            msg = \"task() requires non-empty string field `description`\"\n            raise ValueError(msg)\n\n        subagent_type = payload.get(\"subagentType\")\n        if not isinstance(subagent_type, str) or not subagent_type:\n            msg = \"task() requires non-empty string field `subagentType`\"\n            raise ValueError(msg)\n\n        raw_label = payload.get(\"label\")\n        if raw_label is not None and not isinstance(raw_label, str):\n            msg = \"task() field `label` must be a string when provided\"\n            raise ValueError(msg)\n        label = raw_label.strip() if isinstance(raw_label, str) else None\n        if label == \"\":\n            label = None\n\n        response_schema = payload.get(\"responseSchema\")\n        if response_schema is not None and not isinstance(response_schema, dict):\n            msg = \"task() field `responseSchema` must be an object when provided\"\n            raise ValueError(msg)\n\n        return description, subagent_type, label, response_schema\n\n    async def _ainvoke_task_on_outer_loop(\n        self,","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/partners/quickjs/langchain_quickjs/_repl.py#L535-L571","documentation":"`_validate_task_payload` rejects JS `task()` calls whose payload has no `subagentType` field, or whose `subagentType` is not a non-empty string. The subagent type selects which configured subagent runs the task; without it dispatch cannot proceed. Raised as a ValueError before subagent dispatch.","triggerScenarios":"JS calls `task({description: '...'})` with `subagentType` missing, `undefined`, `null`, non-string, or `''`.","commonSituations":"Model-generated JS forgetting the second required field, using snake_case `subagent_type` instead of camelCase `subagentType`, or passing a JS value that marshals to a non-string (e.g. a number or object).","solutions":["Pass a non-empty string `subagentType` matching a configured subagent: `task({description: 'X', subagentType: 'researcher'})`","Verify the subagentType name against the subagents configured for the eval","Fix prompt/schema so the model emits camelCase `subagentType`"],"exampleFix":"// before\nawait task({ description: 'Search docs', subagent_type: 'researcher' })\n// after\nawait task({ description: 'Search docs', subagentType: 'researcher' })","handlingStrategy":"validation","validationCode":"function canCallTask(p) {\n  return typeof p === 'object' && p !== null\n    && typeof p.subagentType === 'string' && p.subagentType.length > 0;\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":"try {\n  await task(payload);\n} catch (e) {\n  if (String(e).includes('subagentType')) {\n    throw new Error('task() payload missing non-empty subagentType');\n  }\n  throw e;\n}","preventionTips":["Use camelCase `subagentType`, never `subagent_type`, in JS","Verify the subagentType string against configured subagents","Template task() calls with both required fields present"],"tags":["validation","quickjs","task-bridge"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}