{"record":{"id":"30b58c8d34ed44d3","repo":"langchain-ai/deepagents","slug":"general-purpose-subagent-must-be-a-mapping-got","errorCode":null,"errorMessage":"`general_purpose_subagent` must be a mapping, got {type(value).__name__}","messagePattern":"`general_purpose_subagent` must be a mapping, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/profiles/harness/harness_profiles.py","lineNumber":866,"sourceCode":"        msg = f\"`{field_name}` must be a list/set of strings, got {type(value).__name__}\"\n        raise TypeError(msg)\n    entries: list[str] = []\n    for entry in value:\n        if not isinstance(entry, str):\n            msg = f\"`{field_name}` entries must be strings, got {type(entry).__name__} ({entry!r})\"\n            raise TypeError(msg)\n        entries.append(entry)\n    return frozenset(entries)\n\n\ndef _coerce_general_purpose_subagent(value: object) -> GeneralPurposeSubagentProfile | None:\n    \"\"\"Validate and construct a `GeneralPurposeSubagentProfile` from a dict value.\"\"\"\n    if value is None:\n        return None\n    if isinstance(value, Mapping):\n        return GeneralPurposeSubagentProfile.from_dict(cast(\"Mapping[str, Any]\", value))\n    msg = f\"`general_purpose_subagent` must be a mapping, got {type(value).__name__}\"\n    raise TypeError(msg)\n\n\ndef _validate_config_middleware_string(entry: object, field_name: str) -> None:\n    \"\"\"Validate grammar of a string `excluded_middleware` entry.\n\n    Runs at `HarnessProfile` / `HarnessProfileConfig` construction so malformed\n    entries fail immediately rather than at assembly time. Checks:\n\n    - Entry is a non-empty string.\n    - Entry does not contain `:`. Class-path (`module:Class`) entries are\n        reserved for a future revision and rejected upfront so config files\n        don't accumulate ambiguous shapes.\n    - Entry does not start with `_`. Private middleware classes live outside\n        the public exclusion surface.\n\n    Scaffolding-class/name rejection and matched-something coverage are\n    deliberately NOT checked here — those need the fully assembled middleware\n    stack.","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/profiles/harness/harness_profiles.py#L848-L884","documentation":"_coerce_general_purpose_subagent converts the general_purpose_subagent value during from_dict. None maps to no subagent, a Mapping is delegated to GeneralPurposeSubagentProfile.from_dict, and anything else raises a TypeError naming the actual type. This enforces the nested-profile schema.","triggerScenarios":"Calling HarnessProfileConfig.from_dict with general_purpose_subagent set to a string, list, or object, e.g. {\"general_purpose_subagent\": \"default\"} instead of a mapping of subagent profile fields.","commonSituations":"Configs written as a named string shorthand for a built-in subagent; passing an already-constructed GeneralPurposeSubagentProfile object into from_dict; YAML config where the nested block was collapsed to a scalar.","solutions":["Provide a mapping of GeneralPurposeSubagentProfile fields, e.g. {\"model\": ..., \"prompt\": ...}.","Pass None to omit the general-purpose subagent entirely.","If you already have a GeneralPurposeSubagentProfile, serialize it with its to_dict() first, then pass the dict."],"exampleFix":"// before\nconfig = HarnessProfileConfig.from_dict({\"general_purpose_subagent\": \"default\"})\n// after\nconfig = HarnessProfileConfig.from_dict({\"general_purpose_subagent\": {\"model\": \"claude-sonnet-4-5\", \"prompt\": \"Research task\"}})","handlingStrategy":"type-guard","validationCode":"gp = data.get(\"general_purpose_subagent\")\nif gp is not None and not isinstance(gp, Mapping):\n    data[\"general_purpose_subagent\"] = gp.to_dict() if hasattr(gp, \"to_dict\") else None","typeGuard":"def is_gp_subagent_dict(value: object) -> TypeGuard[dict[str, Any] | None]:\n    return value is None or isinstance(value, Mapping)","tryCatchPattern":"try:\n    config = HarnessProfileConfig.from_dict(data)\nexcept TypeError as e:\n    if \"general_purpose_subagent must be a mapping\" in str(e):\n        data[\"general_purpose_subagent\"] = data[\"general_purpose_subagent\"].to_dict()\n        config = HarnessProfileConfig.from_dict(data)\n    else:\n        raise","preventionTips":["Pass a mapping (or None) for general_purpose_subagent — never a string shorthand or live object.","Serialize existing GeneralPurposeSubagentProfile instances with to_dict() before nesting.","Check nested blocks in YAML/JSON configs were not collapsed to scalars."],"tags":["python","type-error","validation","deserialization"],"backgroundTag":"type-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}