{"record":{"id":"78c9e0c2777b2bab","repo":"huggingface/smolagents","slug":"input-input-name-types-invalid-types-must-b","errorCode":null,"errorMessage":"Input '{input_name}': types {invalid_types} must be one of {AUTHORIZED_TYPES}","messagePattern":"Input '(.+?)': types (.+?) must be one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/smolagents/tools.py","lineNumber":194,"sourceCode":"            )\n            # Get input_types as a list, whether from a string or list\n            if isinstance(input_content[\"type\"], str):\n                input_types = [input_content[\"type\"]]\n            elif isinstance(input_content[\"type\"], list):\n                input_types = input_content[\"type\"]\n                # Check if all elements are strings\n                if not all(isinstance(t, str) for t in input_types):\n                    raise TypeError(\n                        f\"Input '{input_name}': when type is a list, all elements must be strings, got {input_content['type']}\"\n                    )\n            else:\n                raise TypeError(\n                    f\"Input '{input_name}': type must be a string or list of strings, got {type(input_content['type']).__name__}\"\n                )\n            # Check all types are authorized\n            invalid_types = [t for t in input_types if t not in AUTHORIZED_TYPES]\n            if invalid_types:\n                raise ValueError(f\"Input '{input_name}': types {invalid_types} must be one of {AUTHORIZED_TYPES}\")\n        # Validate output type\n        assert getattr(self, \"output_type\", None) in AUTHORIZED_TYPES\n\n        # Validate forward function signature, except for Tools that use a \"generic\" signature (PipelineTool, SpaceToolWrapper, LangChainToolWrapper)\n        if not (\n            hasattr(self, \"skip_forward_signature_validation\")\n            and getattr(self, \"skip_forward_signature_validation\") is True\n        ):\n            signature = inspect.signature(self.forward)\n            actual_keys = set(key for key in signature.parameters.keys() if key != \"self\")\n            expected_keys = set(self.inputs.keys())\n            if actual_keys != expected_keys:\n                raise Exception(\n                    f\"In tool '{self.name}', 'forward' method parameters were {actual_keys}, but expected {expected_keys}. \"\n                    f\"It should take 'self' as its first argument, then its next arguments should match the keys of tool attribute 'inputs'.\"\n                )\n\n            json_schema = _convert_type_hints_to_json_schema(self.forward, error_on_missing_type_hints=False)[","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/tools.py#L176-L212","documentation":"smolagents restricts tool input/output types to the AUTHORIZED_TYPES set (string, boolean, integer, number, image, audio, video, any, nullable, etc.). Any input type not in this list raises a ValueError listing the invalid types. This restriction exists because types are serialized into the tool-calling schema presented to the LLM.","triggerScenarios":"Declaring an input with \"type\": \"str\", \"type\": \"float\", \"type\": \"file\", or any string/list entry not in AUTHORIZED_TYPES when instantiating a Tool subclass.","commonSituations":"Using Python type names ('str', 'int', 'float') instead of the JSON-style names ('string', 'integer', 'number'); inventing types like 'filepath' or 'image_url' not supported by the library; version changes that add/remove authorized types.","solutions":["Use only authorized type names: \"string\", \"boolean\", \"integer\", \"number\", \"image\", \"audio\", \"video\", \"any\" (check AUTHORIZED_TYPES in smolagents.gradio_ui/tool docs for your version)","Replace 'str'->'string', 'int'->'integer', 'float'->'number'","For arbitrary objects use \"any\""],"exampleFix":"# before\nself.inputs = {\"a\": {\"type\": \"int\", \"description\": \"count\"}}\n# after\nself.inputs = {\"a\": {\"type\": \"integer\", \"description\": \"count\"}}","handlingStrategy":"validation","validationCode":"from smolagents.tools import AUTHORIZED_TYPES\ninvalid = [t for spec in MyTool.inputs.values() for t in ([spec['type']] if isinstance(spec['type'], str) else spec['type']) if t not in AUTHORIZED_TYPES]\nassert not invalid, f\"Invalid types: {invalid}\"","typeGuard":"AUTHORIZED = {\"string\",\"boolean\",\"integer\",\"number\",\"image\",\"audio\",\"video\",\"any\"}\ndef uses_authorized_types(inputs: dict) -> bool:\n    return all(set([s['type']] if isinstance(s['type'], str) else s['type']) <= AUTHORIZED for s in inputs.values())","tryCatchPattern":null,"preventionTips":["Memorize the JSON-style names: string/integer/number/boolean, not str/int/float/bool","Check AUTHORIZED_TYPES in your installed version before using exotic types","Use 'any' for arbitrary JSON-serializable payloads"],"tags":["smolagents","tool","authorized-types","validation"],"backgroundTag":"unauthorized-type-in-schema","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}