langchain-ai/deepagents · error · TypeError

`enabled` must be bool or None, got {type(enabled).__name__}

Error message

`enabled` must be bool or None, got {type(enabled).__name__}

What it means

from_dict type-checks each value: `enabled` must be a bool or None. Any other type (str, int, etc.) raises TypeError to fail fast on malformed config rather than coerce implicitly.

Source

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

                `system_prompt` keys.

        Returns:
            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.

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Convert to a real bool: {'enabled': True}.
  2. Parse the string in the caller: enabled=val.lower() == 'true' for 'true'/'false'.
  3. Ensure YAML/JSON unquotes boolean literals (enabled: true).

Example fix

// before
from_dict({"enabled": "true"})
// after
from_dict({"enabled": True})
Defensive patterns

Strategy: type-guard

Validate before calling

if not (enabled is None or isinstance(enabled, bool)):
    raise TypeError("enabled must be bool or None")

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Passing {'enabled': 'true'} or {'enabled': 1} to GeneralPurposeSubagentProfile.from_dict; YAML configs that parse on/off ambiguously are usually fine but quoted "yes"/'true' strings are not.

Common situations: Quoted booleans in YAML/JSON ('enabled: "true"'); 0/1 flags from environment parsing; programmatic dicts built from CLI string args.

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/8285d480b7793d4b. Report an issue: GitHub.