OpenBMB/ChatDev · error · ConfigError

max_items must be a positive integer

Error message

max_items must be a positive integer

What it means

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.

Source

Thrown at entity/configs/node/memory.py:257

            required=False,
            description="Embedding used for file memory",
            child=EmbeddingConfig,
        ),
    }


@dataclass
class BlackboardMemoryConfig(BaseConfig):
    memory_path: str | None = None
    max_items: int = 1000

    @classmethod
    def from_dict(cls, data: Mapping[str, Any], *, path: str) -> "BlackboardMemoryConfig":
        mapping = require_mapping(data, path)
        memory_path = optional_str(mapping, "memory_path", path)
        max_items_value = mapping.get("max_items", 1000)
        if not isinstance(max_items_value, int) or max_items_value <= 0:
            raise ConfigError("max_items must be a positive integer", extend_path(path, "max_items"))
        return cls(memory_path=memory_path, max_items=max_items_value, path=path)

    FIELD_SPECS = {
        "memory_path": ConfigFieldSpec(
            name="memory_path",
            display_name="Blackboard Path",
            type_hint="str",
            required=False,
            description="JSON path for blackboard memory writing. Pass 'auto' to auto-create in working directory, valid for this run only",
            default="auto",
            advance=True,
        ),
        "max_items": ConfigFieldSpec(
            name="max_items",
            display_name="Maximum Items",
            type_hint="int",
            required=False,
            default=1000,

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Set max_items to a positive integer, e.g. 1000
  2. Ensure serializers emit ints not floats (or int() the value before building the dict)
  3. Use a large bound instead of 0 if you effectively want no limit

Example fix

# before
{"max_items": 100.5}
# after
{"max_items": 1000}
Defensive patterns

Strategy: validation

Validate before calling

mi = data.get('max_items', 1000)
if not isinstance(mi, int) or isinstance(mi, bool) or mi <= 0:
    data['max_items'] = 1000

Type guard

def max_items_ok(data: dict) -> bool:
    mi = data.get('max_items', 1000)
    return isinstance(mi, int) and not isinstance(mi, bool) and mi > 0

Try / catch

try:
    BlackboardMemoryConfig.from_dict(data, path='bm')
except ConfigError as e:
    if 'max_items' in e.path:
        data['max_items'] = 1000
        BlackboardMemoryConfig.from_dict(data, path='bm')
    else:
        raise

Prevention

When it happens

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

Common situations: 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.

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 OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/56ccf839a0c82c3e. Report an issue: GitHub.