{"record":{"id":"264a719bf36e03ab","repo":"langchain-ai/deepagents","slug":"system-prompt-must-be-str-or-none-got-type-sys","errorCode":null,"errorMessage":"`system_prompt` must be str or None, got {type(system_prompt).__name__}","messagePattern":"`system_prompt` must be str or None, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/profiles/harness/harness_profiles.py","lineNumber":187,"sourceCode":"            TypeError: If `data` contains unknown keys, or if any value has\n                the wrong type.\n        \"\"\"\n        unknown = set(data.keys()) - _GENERAL_PURPOSE_SUBAGENT_KEYS\n        if unknown:\n            msg = f\"Unknown keys in GeneralPurposeSubagentProfile dict: {sorted(unknown)}\"\n            raise TypeError(msg)\n        enabled = data.get(\"enabled\")\n        description = data.get(\"description\")\n        system_prompt = data.get(\"system_prompt\")\n        if enabled is not None and not isinstance(enabled, bool):\n            msg = f\"`enabled` must be bool or None, got {type(enabled).__name__}\"\n            raise TypeError(msg)\n        if description is not None and not isinstance(description, str):\n            msg = f\"`description` must be str or None, got {type(description).__name__}\"\n            raise TypeError(msg)\n        if system_prompt is not None and not isinstance(system_prompt, str):\n            msg = f\"`system_prompt` must be str or None, got {type(system_prompt).__name__}\"\n            raise TypeError(msg)\n        return cls(enabled=enabled, description=description, system_prompt=system_prompt)\n\n\n@dataclass(frozen=True)\nclass HarnessProfileConfig:\n    \"\"\"Declarative harness-profile config for YAML/JSON-backed profiles.\n\n    !!! beta\n\n        `deepagents.profiles` exposes beta APIs that may receive minor changes in\n        future releases. Refer to the [versioning documentation](https://docs.langchain.com/oss/python/versioning)\n        for more details.\n\n    A `HarnessProfileConfig` contains the file-friendly subset of harness\n    settings: plain strings, bools, lists, and nested dicts that can be loaded\n    from YAML or JSON. For in-code/runtime-only adjustments such as\n    `extra_middleware` or class-form `excluded_middleware`, use\n    `HarnessProfile` instead.","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/profiles/harness/harness_profiles.py#L169-L205","documentation":"from_dict requires `system_prompt` to be a str or None. Non-string values raise TypeError, because the prompt is interpolated directly into the agent's instructions and must be text.","triggerScenarios":"Passing {'system_prompt': 42}, a list of prompt chunks, or a nested dict/structured prompt object to GeneralPurposeSubagentProfile.from_dict.","commonSituations":"Structured prompt configs (arrays of messages) from other frameworks pasted into the profile config; numeric defaults; YAML flow lists where a scalar was intended.","solutions":["Flatten to a single string before calling from_dict.","Join chunks: '\\n'.join(prompt_parts).","Use the framework's message-list API instead of system_prompt if a structured prompt is needed."],"exampleFix":"// before\nfrom_dict({\"system_prompt\": [\"You are\", \"an agent\"]})\n// after\nfrom_dict({\"system_prompt\": \"You are an agent\"})","handlingStrategy":"type-guard","validationCode":"if not (system_prompt is None or isinstance(system_prompt, str)):\n    raise TypeError(\"system_prompt must be str or None\")","typeGuard":"def is_str_or_none(v: object) -> bool:\n    return v is None or isinstance(v, str)","tryCatchPattern":"try:\n    profile = GeneralPurposeSubagentProfile.from_dict(data)\nexcept TypeError as e:\n    logging.error(\"bad 'system_prompt' value: %s\", e)","preventionTips":["Flatten structured prompt lists to a single string first","Validate prompt config shape at load time"],"tags":["python","profiles","type-error"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}