{"record":{"id":"56ccf839a0c82c3e","repo":"OpenBMB/ChatDev","slug":"max-items-must-be-a-positive-integer","errorCode":null,"errorMessage":"max_items must be a positive integer","messagePattern":"max_items must be a positive integer","errorType":"validation","errorClass":"ConfigError","httpStatus":null,"severity":"error","filePath":"entity/configs/node/memory.py","lineNumber":257,"sourceCode":"            required=False,\n            description=\"Embedding used for file memory\",\n            child=EmbeddingConfig,\n        ),\n    }\n\n\n@dataclass\nclass BlackboardMemoryConfig(BaseConfig):\n    memory_path: str | None = None\n    max_items: int = 1000\n\n    @classmethod\n    def from_dict(cls, data: Mapping[str, Any], *, path: str) -> \"BlackboardMemoryConfig\":\n        mapping = require_mapping(data, path)\n        memory_path = optional_str(mapping, \"memory_path\", path)\n        max_items_value = mapping.get(\"max_items\", 1000)\n        if not isinstance(max_items_value, int) or max_items_value <= 0:\n            raise ConfigError(\"max_items must be a positive integer\", extend_path(path, \"max_items\"))\n        return cls(memory_path=memory_path, max_items=max_items_value, path=path)\n\n    FIELD_SPECS = {\n        \"memory_path\": ConfigFieldSpec(\n            name=\"memory_path\",\n            display_name=\"Blackboard Path\",\n            type_hint=\"str\",\n            required=False,\n            description=\"JSON path for blackboard memory writing. Pass 'auto' to auto-create in working directory, valid for this run only\",\n            default=\"auto\",\n            advance=True,\n        ),\n        \"max_items\": ConfigFieldSpec(\n            name=\"max_items\",\n            display_name=\"Maximum Items\",\n            type_hint=\"int\",\n            required=False,\n            default=1000,","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/entity/configs/node/memory.py#L239-L275","documentation":"BlackboardMemoryConfig.from_dict requires 'max_items' (default 1000) to be a strict int (bools excluded by the isinstance check semantics for int? — note bool is an int subclass, but the <= 0 guard catches False) and strictly positive.","triggerScenarios":"Passing max_items as a float like 100.5 (fails isinstance int), a string like '500' (no coercion here, unlike loop configs), 0, or a negative number.","commonSituations":"Assuming this field coerces like max_iterations/max_duration do — it does not; JSON floats where ints were intended (100.0 from some serializers); zeroing the cap to 'disable' the blackboard.","solutions":["Set max_items to a positive integer, e.g. 1000","Ensure serializers emit ints not floats (or int() the value before building the dict)","Use a large bound instead of 0 if you effectively want no limit"],"exampleFix":"# before\n{\"max_items\": 100.5}\n# after\n{\"max_items\": 1000}","handlingStrategy":"validation","validationCode":"mi = data.get('max_items', 1000)\nif not isinstance(mi, int) or isinstance(mi, bool) or mi <= 0:\n    data['max_items'] = 1000","typeGuard":"def max_items_ok(data: dict) -> bool:\n    mi = data.get('max_items', 1000)\n    return isinstance(mi, int) and not isinstance(mi, bool) and mi > 0","tryCatchPattern":"try:\n    BlackboardMemoryConfig.from_dict(data, path='bm')\nexcept ConfigError as e:\n    if 'max_items' in e.path:\n        data['max_items'] = 1000\n        BlackboardMemoryConfig.from_dict(data, path='bm')\n    else:\n        raise","preventionTips":["Note: unlike max_iterations, no str->int coercion happens here","Ensure serializers emit ints (int() floats like 100.0)","Use a large cap instead of 0 to 'disable' limits"],"tags":["config","memory","blackboard","validation","python"],"backgroundTag":"schema-validation-failed","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}