{"record":{"id":"979475809c87dbbe","repo":"agentscope-ai/agentscope","slug":"duplicate-chunker-type-cls-chunker-type-r-seen","errorCode":null,"errorMessage":"Duplicate chunker_type {cls.chunker_type!r}: {seen_chunker_types[cls.chunker_type].__name__} and {cls.__name__}.","messagePattern":"Duplicate chunker_type (.+?): (.+?) and (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/app/_app.py","lineNumber":342,"sourceCode":"        chunker_classes = list(\n            knowledge_chunkers\n            if knowledge_chunkers is not None\n            else [ApproxTokenChunker],\n        )\n        # Backward compatibility: the deprecated ``knowledge_chunker``\n        # instance is only used for its class.\n        if \"knowledge_chunker\" in kwargs:\n            logger.warning(\n                \"The `knowledge_chunker` argument of create_app() is \"\n                \"deprecated, use `knowledge_chunkers` instead.\",\n            )\n            legacy_cls = type(kwargs[\"knowledge_chunker\"])\n            if legacy_cls not in chunker_classes:\n                chunker_classes.append(legacy_cls)\n        seen_chunker_types: dict[str, Type[ChunkerBase]] = {}\n        for cls in chunker_classes:\n            if cls.chunker_type in seen_chunker_types:\n                raise ValueError(\n                    f\"Duplicate chunker_type {cls.chunker_type!r}: \"\n                    f\"{seen_chunker_types[cls.chunker_type].__name__} and \"\n                    f\"{cls.__name__}.\",\n                )\n            seen_chunker_types[cls.chunker_type] = cls\n        app.state.knowledge_chunkers = chunker_classes\n        app.state.blob_store = (\n            blob_store\n            if blob_store is not None\n            else LocalBlobStore(root_dir=\"./blobs\")\n        )\n    else:\n        app.state.knowledge_parsers = knowledge_parsers\n        app.state.knowledge_chunkers = knowledge_chunkers\n        app.state.blob_store = blob_store\n    app.state.enable_index_worker = (\n        enable_index_worker and knowledge_base_manager is not None\n    )","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/app/_app.py#L324-L360","documentation":"create_app indexes knowledge chunkers by their chunker_type string; two chunker classes declaring the same chunker_type would overwrite each other in the registry, so configuration raises ValueError naming both conflicting classes.","triggerScenarios":"Registering two ChunkerBase subclasses (including via the legacy knowledge_chunker kwarg) whose chunker_type class attribute matches, e.g. a custom chunker reusing 'recursive' or another built-in type string.","commonSituations":"Writing a custom chunker and forgetting to set a unique chunker_type; subclassing a built-in chunker without overriding chunker_type; mixing legacy knowledge_chunker kwarg with a chunker list containing the same class's type.","solutions":["Set a unique chunker_type on your custom chunker class","If subclassing a built-in chunker, override chunker_type with a new name","Remove duplicate chunker classes from the registration list"],"exampleFix":"# before\nclass MyChunker(RecursiveChunker):\n    ...  # inherits chunker_type='recursive'\n\n# after\nclass MyChunker(RecursiveChunker):\n    chunker_type = \"my_recursive\"\n    ...","handlingStrategy":"validation","validationCode":"def chunker_types_unique(classes) -> bool:\n    types = [c.chunker_type for c in classes]\n    return len(types) == len(set(types))","typeGuard":null,"tryCatchPattern":"try:\n    app = create_app(...)\nexcept ValueError as e:\n    if \"Duplicate chunker_type\" in str(e):\n        # set unique chunker_type on the named class and retry\n        ...","preventionTips":["Always override chunker_type when subclassing a chunker","Namespace custom chunker types, e.g. 'myorg_recursive'"],"tags":["agentscope","app","chunker","duplicate-registration"],"backgroundTag":"duplicate-registration-key","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}