{"record":{"id":"7e7e0a927045538a","repo":"affaan-m/ECC","slug":"pass-either-config-or-promptbuilder-keyword-option","errorCode":null,"errorMessage":"Pass either config or PromptBuilder keyword options, not both","messagePattern":"Pass either config or PromptBuilder keyword options, not both","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llm/prompt/builder.py","lineNumber":33,"sourceCode":"    include_tools_in_system: bool = True\n    tool_format: str = \"native\"\n\n\nclass PromptBuilder:\n    def __init__(\n        self,\n        config: PromptConfig | None = None,\n        *,\n        system_template: str | None = None,\n        user_template: str | None = None,\n        include_tools_in_system: bool | None = None,\n        tool_format: str | None = None,\n    ) -> None:\n        if config is not None and any(\n            value is not None\n            for value in (system_template, user_template, include_tools_in_system, tool_format)\n        ):\n            raise ValueError(\"Pass either config or PromptBuilder keyword options, not both\")\n\n        if config is None:\n            defaults = PromptConfig()\n            config = PromptConfig(\n                system_template=(\n                    system_template if system_template is not None else defaults.system_template\n                ),\n                user_template=(\n                    user_template if user_template is not None else defaults.user_template\n                ),\n                include_tools_in_system=(\n                    include_tools_in_system\n                    if include_tools_in_system is not None\n                    else defaults.include_tools_in_system\n                ),\n                tool_format=(\n                    tool_format if tool_format is not None else defaults.tool_format\n                ),","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/src/llm/prompt/builder.py#L15-L51","documentation":"PromptBuilder.__init__ enforces mutual exclusivity: you may pass either a PromptConfig object OR individual keyword template options (system_template, user_template, include_tools_in_system, tool_format), never both. Mixing them is ambiguous, so a ValueError is raised.","triggerScenarios":"PromptBuilder(config=cfg, system_template='...') or PromptBuilder(config=cfg, tool_format='xml') — any combination of a non-None config with at least one non-None template option.","commonSituations":"Refactoring from keyword-style construction to config objects and leaving a stray keyword argument; wrapping the builder in a helper that forwards both user config and overrides.","solutions":["Remove the keyword options and put all settings into the PromptConfig","Or drop the config argument and pass only keyword options","In wrapper code, branch: build config from kwargs when any kwarg is set, else pass config through"],"exampleFix":"// before\nPromptBuilder(config=cfg, system_template='You are...')\n// after\ncfg = PromptConfig(system_template='You are...', **base)\nPromptBuilder(config=cfg)","handlingStrategy":"validation","validationCode":"opts = {k: v for k, v in kwargs.items() if v is not None}\nif config is not None and opts:\n    raise ValueError('pass config or kwargs, not both')","typeGuard":null,"tryCatchPattern":"try:\n    builder = PromptBuilder(config=cfg, **overrides)\nexcept ValueError as e:\n    if 'not both' in str(e):\n        logger.warning('conflicting builder args; preferring kwargs')\n        builder = PromptBuilder(**overrides)","preventionTips":["Pick one construction style (config object) project-wide","In wrappers, merge overrides into config instead of forwarding both","Add a lint rule or helper factory that hides the raw constructor"],"tags":["value-error","conflicting-options","constructor","llm"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}