{"record":{"id":"1d6b1ccb18a0e76c","repo":"huggingface/smolagents","slug":"super-argument-1-must-be-type","errorCode":null,"errorMessage":"super() argument 1 must be type","messagePattern":"super\\(\\) argument 1 must be type","errorType":"exception","errorClass":"InterpreterError","httpStatus":null,"severity":"error","filePath":"src/smolagents/local_python_executor.py","lineNumber":894,"sourceCode":"        if keyword.arg is None:\n            # **kwargs unpacking\n            starred_dict = evaluate_ast(keyword.value, state, static_tools, custom_tools, authorized_imports)\n            if not isinstance(starred_dict, dict):\n                raise InterpreterError(f\"Cannot unpack non-dict value in **kwargs: {type(starred_dict).__name__}\")\n            kwargs.update(starred_dict)\n        else:\n            # Normal keyword argument\n            kwargs[keyword.arg] = evaluate_ast(keyword.value, state, static_tools, custom_tools, authorized_imports)\n\n    if func_name == \"super\":\n        if not args:\n            if \"__class__\" in state and \"self\" in state:\n                return super(state[\"__class__\"], state[\"self\"])\n            else:\n                raise InterpreterError(\"super() needs at least one argument\")\n        cls = args[0]\n        if not isinstance(cls, type):\n            raise InterpreterError(\"super() argument 1 must be type\")\n        if len(args) == 1:\n            return super(cls)\n        elif len(args) == 2:\n            instance = args[1]\n            return super(cls, instance)\n        else:\n            raise InterpreterError(\"super() takes at most 2 arguments\")\n    elif func_name == \"print\":\n        state[\"_print_outputs\"] += \" \".join(map(str, args)) + \"\\n\"\n        return None\n    else:  # Assume it's a callable object\n        if (inspect.getmodule(func) == builtins) and inspect.isbuiltin(func) and (func not in static_tools.values()):\n            raise InterpreterError(\n                f\"Invoking a builtin function that has not been explicitly added as a tool is not allowed ({func_name}).\"\n            )\n        if (\n            hasattr(func, \"__name__\")\n            and func.__name__.startswith(\"__\")","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/local_python_executor.py#L876-L912","documentation":"super() was called with at least one argument, but the first argument is not a Python type (class). super(Cls, obj) requires the first argument to be a class object.","triggerScenarios":"super(instance, self), super('ClassName', self), super(type(self), self) where type(self) evaluated to a non-type, or super(self.__class__.__name__, self).","commonSituations":"Agent code passes the instance instead of the class as first arg; passing the class name as a string; a variable shadowing the class name holding something else.","solutions":["Pass the class itself, not an instance or string: super(B, self)","Check isinstance(first_arg, type) before calling","Ensure the class name is not shadowed by a variable in state"],"exampleFix":"# before\nsuper(b, self).run()   # b is an instance\n# after\nsuper(B, self).run()   # B is the class","handlingStrategy":"type-guard","validationCode":"cls = args[0]\nassert isinstance(cls, type), f'super() arg1 must be a class, got {type(cls).__name__}'\nsuper(cls, self)","typeGuard":"def is_class(v) -> bool:\n    return isinstance(v, type)","tryCatchPattern":"try:\n    evaluate_python(code, ...)\nexcept InterpreterError as e:\n    if 'argument 1 must be type' in str(e):\n        # pass the class object instead of instance/string and retry","preventionTips":["Pass the class itself as super()'s first argument","Don't shadow class names with variables"],"tags":["python-executor","super","type-check","smolagents"],"backgroundTag":"invalid-super-argument","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}