langchain-ai/deepagents · error · TypeError

`description` must be str or None, got {type(description).__

Error message

`description` must be str or None, got {type(description).__name__}

What it means

from_dict requires `description` to be a str or None. Non-string values (numbers, lists, dicts, bools) raise TypeError so the profile dataclass never holds an invalid description.

Source

Thrown at libs/deepagents/deepagents/profiles/harness/harness_profiles.py:184

            A new `GeneralPurposeSubagentProfile`.

        Raises:
            TypeError: If `data` contains unknown keys, or if any value has
                the wrong type.
        """
        unknown = set(data.keys()) - _GENERAL_PURPOSE_SUBAGENT_KEYS
        if unknown:
            msg = f"Unknown keys in GeneralPurposeSubagentProfile dict: {sorted(unknown)}"
            raise TypeError(msg)
        enabled = data.get("enabled")
        description = data.get("description")
        system_prompt = data.get("system_prompt")
        if enabled is not None and not isinstance(enabled, bool):
            msg = f"`enabled` must be bool or None, got {type(enabled).__name__}"
            raise TypeError(msg)
        if description is not None and not isinstance(description, str):
            msg = f"`description` must be str or None, got {type(description).__name__}"
            raise TypeError(msg)
        if system_prompt is not None and not isinstance(system_prompt, str):
            msg = f"`system_prompt` must be str or None, got {type(system_prompt).__name__}"
            raise TypeError(msg)
        return cls(enabled=enabled, description=description, system_prompt=system_prompt)


@dataclass(frozen=True)
class HarnessProfileConfig:
    """Declarative harness-profile config for YAML/JSON-backed profiles.

    !!! beta

        `deepagents.profiles` exposes beta APIs that may receive minor changes in
        future releases. Refer to the [versioning documentation](https://docs.langchain.com/oss/python/versioning)
        for more details.

    A `HarnessProfileConfig` contains the file-friendly subset of harness
    settings: plain strings, bools, lists, and nested dicts that can be loaded

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Convert to str: description=str(value) if intentional.
  2. Join list lines: '\n'.join(lines).
  3. Move structured metadata to a different config section.

Example fix

// before
from_dict({"description": ["line1", "line2"]})
// after
from_dict({"description": "line1\nline2"})
Defensive patterns

Strategy: type-guard

Validate before calling

if not (description is None or isinstance(description, str)):
    raise TypeError("description must be str or None")

Type guard

def is_str_or_none(v: object) -> bool:
    return v is None or isinstance(v, str)

Try / catch

try:
    profile = GeneralPurposeSubagentProfile.from_dict(data)
except TypeError as e:
    logging.error("bad 'description' value: %s", e)

Prevention

When it happens

Trigger: Passing {'description': 123}, {'description': ['a','b']}, or a nested mapping as the description in the general-purpose subagent dict.

Common situations: Config where a numeric ID or list of lines was put in the description field; tooling that emits structured metadata where a plain string is expected.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/0504511ce2280c1c. Report an issue: GitHub.