{"record":{"id":"a5dbe14a6ffdf35f","repo":"huggingface/smolagents","slug":"only-markdown-is-supported-for-a-string-argument","errorCode":null,"errorMessage":"Only 'markdown' is supported for a string argument to `code_block_tags`.","messagePattern":"Only 'markdown' is supported for a string argument to `code_block_tags`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/smolagents/agents.py","lineNumber":1557,"sourceCode":"        use_structured_outputs_internally: bool = False,\n        code_block_tags: str | tuple[str, str] | None = None,\n        **kwargs,\n    ):\n        self.additional_authorized_imports = additional_authorized_imports if additional_authorized_imports else []\n        self.authorized_imports = sorted(set(BASE_BUILTIN_MODULES) | set(self.additional_authorized_imports))\n        self.max_print_outputs_length = max_print_outputs_length\n        self._use_structured_outputs_internally = use_structured_outputs_internally\n        if self._use_structured_outputs_internally:\n            prompt_templates = prompt_templates or yaml.safe_load(\n                importlib.resources.files(\"smolagents.prompts\").joinpath(\"structured_code_agent.yaml\").read_text()\n            )\n        else:\n            prompt_templates = prompt_templates or yaml.safe_load(\n                importlib.resources.files(\"smolagents.prompts\").joinpath(\"code_agent.yaml\").read_text()\n            )\n\n        if isinstance(code_block_tags, str) and not code_block_tags == \"markdown\":\n            raise ValueError(\"Only 'markdown' is supported for a string argument to `code_block_tags`.\")\n        self.code_block_tags = (\n            code_block_tags\n            if isinstance(code_block_tags, tuple)\n            else (\"```python\", \"```\")\n            if code_block_tags == \"markdown\"\n            else (\"<code>\", \"</code>\")\n        )\n\n        super().__init__(\n            tools=tools,\n            model=model,\n            prompt_templates=prompt_templates,\n            planning_interval=planning_interval,\n            **kwargs,\n        )\n        self.stream_outputs = stream_outputs\n        if self.stream_outputs and not hasattr(self.model, \"generate_stream\"):\n            raise ValueError(","sourceCodeStart":1539,"sourceCodeEnd":1575,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/agents.py#L1539-L1575","documentation":"CodeAgent.__init__ accepts code_block_tags as either a string or a tuple. The only accepted string is the sentinel 'markdown' (which maps to ('```python', '```')); any other string is rejected — custom tags must be passed as an explicit (opening, closing) tuple.","triggerScenarios":"Constructing CodeAgent(model=..., code_block_tags='xml') or any string other than 'markdown'.","commonSituations":"Users assuming code_block_tags takes a format name like 'xml' or 'html'; migrating configurations where a single string tag was expected.","solutions":["Pass a tuple: code_block_tags=('<code>', '</code>') for custom tags.","Or use the string 'markdown' if you want the default ```python fences.","Or omit the parameter entirely to accept the default <code> tags."],"exampleFix":"# before\nagent = CodeAgent(model=model, tools=[], code_block_tags='xml')\n\n# after\nagent = CodeAgent(model=model, tools=[], code_block_tags=('<code>', '</code>'))","handlingStrategy":"validation","validationCode":"assert isinstance(code_block_tags, tuple) or code_block_tags == 'markdown'\nagent = CodeAgent(model=model, tools=[], code_block_tags=code_block_tags)","typeGuard":"def valid_code_block_tags(v) -> bool:\n    return isinstance(v, tuple) and len(v) == 2 or v == 'markdown'","tryCatchPattern":null,"preventionTips":["Pass code_block_tags as an explicit (open, close) tuple for custom formats.","Reserve the string form for the 'markdown' sentinel only.","Omit the parameter to use defaults when unsure."],"tags":["smolagents","codeagent","configuration","input-validation"],"backgroundTag":"invalid-enum-config-value","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}