{"record":{"id":"6782285da8c0366e","repo":"agentscope-ai/agentscope","slug":"duplicate-sub-agent-template-type-s-duplicates","errorCode":null,"errorMessage":"Duplicate sub_agent_template type(s): {duplicates}","messagePattern":"Duplicate sub_agent_template type\\(s\\): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/app/_app.py","lineNumber":373,"sourceCode":"        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    )\n    app.state.enable_channel_worker = enable_channel_worker\n\n    # Validate custom sub-agent templates for duplicate types and store in\n    #  app.state\n    templates = custom_subagent_templates or []\n    seen_types: set[str] = set()\n    duplicates: set[str] = set()\n    for t in templates:\n        if t.type in seen_types:\n            duplicates.add(t.type)\n        seen_types.add(t.type)\n    if duplicates:\n        raise ValueError(\n            f\"Duplicate sub_agent_template type(s): {duplicates}\",\n        )\n    app.state.custom_subagent_templates = {t.type: t for t in templates}\n\n    # Built-in routers\n    for router in (\n        agent_router,\n        chat_router,\n        credential_router,\n        health_router,\n        hub_router,\n        knowledge_base_router,\n        mcp_router,\n        schedule_router,\n        session_router,\n        skill_router,\n        workspace_router,\n        model_router,","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/app/_app.py#L355-L391","documentation":"create_app builds a mapping of custom sub-agent templates keyed by their type string; duplicate types would silently shadow one template, so configuration collects the duplicates into a set and raises ValueError.","triggerScenarios":"Passing multiple SubAgentTemplate objects with the same .type to create_app, e.g. two templates both named 'coder'.","commonSituations":"Dynamically generating templates from config files where types collide; copy-pasting a template and forgetting to change its type; merging template lists from multiple modules.","solutions":["Give each SubAgentTemplate a unique type string","Deduplicate the templates list before passing it to create_app","If templates come from config, validate type uniqueness at config load time"],"exampleFix":"# before\ntemplates = [\n    SubAgentTemplate(type=\"coder\", ...),\n    SubAgentTemplate(type=\"coder\", ...),\n]\n\n# after\ntemplates = [\n    SubAgentTemplate(type=\"coder\", ...),\n    SubAgentTemplate(type=\"reviewer\", ...),\n]","handlingStrategy":"validation","validationCode":"def template_types_unique(templates) -> bool:\n    types = [t.type for t in templates]\n    return len(types) == len(set(types))","typeGuard":null,"tryCatchPattern":"try:\n    app = create_app(...)\nexcept ValueError as e:\n    if \"Duplicate sub_agent_template\" in str(e):\n        dedupe = {t.type: t for t in templates}\n        templates = list(dedupe.values())\n        app = create_app(...)","preventionTips":["Derive template type from a stable unique key (e.g. name)","Add a config-load-time uniqueness assertion for template types"],"tags":["agentscope","app","subagent","templates","duplicate-registration"],"backgroundTag":"duplicate-registration-key","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}