{"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/01e15490f04e29cfefe3896951f43db46994d8ee/src/llm/prompt/builder.py#L15-L51","documentation":"PromptBuilder.__init__ accepts either a PromptConfig object OR individual keyword overrides (system_template, user_template, include_tools_in_system, tool_format), but not both. Passing config plus any non-None keyword is rejected to keep the two construction modes unambiguous.","triggerScenarios":"Passing PromptBuilder(my_config, system_template='X'); passing config=cfg and tool_format='openai' together; refactoring code that previously built a config and now also passes a per-call override.","commonSituations":"Migrating from one construction style to the other and forgetting to remove the old argument; helper functions that thread both a config object and override kwargs through to the builder.","solutions":["If you have a config, pass only the config and edit its fields before construction.","If you want overrides, pass only the keyword arguments — the builder will assemble a PromptConfig from them.","Use get_provider_builder(provider_name) for the standard provider presets instead of mixing config and kwargs."],"exampleFix":"# before\ncfg = PromptConfig(tool_format='openai')\nbuilder = PromptBuilder(cfg, system_template='You are X')\n\n# after (option A: edit the config)\ncfg = PromptConfig(tool_format='openai', system_template='You are X')\nbuilder = PromptBuilder(cfg)\n\n# after (option B: kwargs only)\nbuilder = PromptBuilder(system_template='You are X', tool_format='openai')","handlingStrategy":"validation","validationCode":"from llm.prompt.builder import PromptBuilder, PromptConfig\n\ndef build_prompt(config: PromptConfig | None = None, **overrides):\n    if config is not None and overrides:\n        raise ValueError('Pass either config or overrides, not both')\n    return PromptBuilder(config, **overrides) if not config else PromptBuilder(config)","typeGuard":null,"tryCatchPattern":"from llm.prompt.builder import PromptBuilder, PromptConfig\ntry:\n    builder = PromptBuilder(config, system_template='X')\nexcept ValueError:\n    builder = PromptBuilder(config)  # drop the override","preventionTips":["Pick one construction style (config object OR kwargs) per call site and stick to it.","Use get_provider_builder(name) for the standard provider presets.","When refactoring, audit helper functions that thread both a config and override kwargs."],"tags":["validation","prompt","builder","llm"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}