{"record":{"id":"7711be2970a096e7","repo":"langchain-ai/deepagents","slug":"response-schema-exceeds-maximum-of-schema-max-pr","errorCode":null,"errorMessage":"response_schema exceeds maximum of {_SCHEMA_MAX_PROPERTIES} properties","messagePattern":"response_schema exceeds maximum of (.+?) properties","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/partners/quickjs/langchain_quickjs/_subagent.py","lineNumber":299,"sourceCode":"            f\" byte limit ({len(serialized)} bytes)\"\n        )\n        raise ValueError(msg)\n\n    def _check(node: dict[str, Any], depth: int, prop_count: list[int]) -> None:\n        if depth > _SCHEMA_MAX_DEPTH:\n            msg = (\n                f\"response_schema exceeds maximum nesting depth of {_SCHEMA_MAX_DEPTH}\"\n            )\n            raise ValueError(msg)\n        props = node.get(\"properties\")\n        if isinstance(props, dict):\n            prop_count[0] += len(props)\n            if prop_count[0] > _SCHEMA_MAX_PROPERTIES:\n                msg = (\n                    \"response_schema exceeds maximum of\"\n                    f\" {_SCHEMA_MAX_PROPERTIES} properties\"\n                )\n                raise ValueError(msg)\n            for value in props.values():\n                if isinstance(value, dict):\n                    _check(value, depth + 1, prop_count)\n        items = node.get(\"items\")\n        if isinstance(items, dict):\n            _check(items, depth + 1, prop_count)\n\n    _check(schema, 0, [0])\n\n\n_DEFAULT_SCHEMA_TITLE = \"subagent_response\"\n\n\ndef _ensure_schema_title(schema: dict[str, Any]) -> dict[str, Any]:\n    \"\"\"Ensure the response schema carries a non-empty top-level ``title``.\n\n    Structured output backends that treat a JSON schema as a function (for\n    example, the OpenAI function-calling path) require a top-level ``title`` to","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/partners/quickjs/langchain_quickjs/_subagent.py#L281-L317","documentation":"Schema validation also tracks a cumulative property count across every nested object and rejects `response_schema` when the total exceeds `_SCHEMA_MAX_PROPERTIES`. The count is shared via `prop_count[0]` across recursive `_check` calls, so the whole schema, not a single level, is bounded.","triggerScenarios":"Passing a `response_schema` whose combined number of `properties` entries across all nested objects exceeds `_SCHEMA_MAX_PROPERTIES` when calling `task()`.","commonSituations":"Auto-generating schemas from wide tables, API responses, or config formats with hundreds of fields; exporting an entire database row schema when only a few columns are needed.","solutions":["Trim the schema to only the properties the subagent must return.","Group rarely used fields into a single `metadata` object or a JSON string field.","Generate the schema programmatically and assert the total property count before calling `task()`.","Check `_SCHEMA_MAX_PROPERTIES` for the exact allowed total."],"exampleFix":"// before\nprops = {col: {\"type\": \"string\"} for col in all_500_table_columns}\nschema = {\"type\": \"object\", \"properties\": props}\n\n// after\nneeded = [\"id\", \"name\", \"created_at\"]\nschema = {\"type\": \"object\", \"properties\": {c: {\"type\": \"string\"} for c in needed}}","handlingStrategy":"validation","validationCode":"def count_props(node, acc=[0]):\n    props = node.get(\"properties\")\n    if isinstance(props, dict):\n        acc[0] += len(props)\n        for v in props.values():\n            if isinstance(v, dict):\n                count_props(v, acc)\n    items = node.get(\"items\")\n    if isinstance(items, dict):\n        count_props(items, acc)\n    return acc[0]\nassert count_props(schema, [0]) <= _SCHEMA_MAX_PROPERTIES, \"too many properties\"","typeGuard":null,"tryCatchPattern":"try:\n    task(prompt=prompt, response_schema=schema)\nexcept ValueError as e:\n    if \"properties\" in str(e):\n        task(prompt=prompt, response_schema=trim_schema_to_essential_fields(schema))","preventionTips":["Select only needed fields when deriving schemas from tables/APIs.","Fold secondary fields into one `metadata` object.","Assert cumulative property count before large batch calls."],"tags":["validation","schema","limits"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}