{"record":{"id":"e055c379c35ced4a","repo":"huggingface/smolagents","slug":"super-takes-at-most-2-arguments","errorCode":null,"errorMessage":"super() takes at most 2 arguments","messagePattern":"super\\(\\) takes at most 2 arguments","errorType":"exception","errorClass":"InterpreterError","httpStatus":null,"severity":"error","filePath":"src/smolagents/local_python_executor.py","lineNumber":901,"sourceCode":"            # 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(\"__\")\n            and func.__name__.endswith(\"__\")\n            and (func.__name__ not in static_tools)\n            and (func.__name__ not in ALLOWED_DUNDER_METHODS)\n        ):\n            raise InterpreterError(f\"Forbidden call to dunder function: {func.__name__}\")\n        return func(*args, **kwargs)\n","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/local_python_executor.py#L883-L919","documentation":"super() accepts at most two arguments (type, object-or-type). The sandboxed interpreter raises this when three or more positional arguments are given.","triggerScenarios":"super(A, obj, extra) or f(*args) unpacking more than two arguments into super().","commonSituations":"Agent code unpacks a tuple with *args that happens to contain extra elements; misunderstanding of super()'s signature.","solutions":["Pass exactly one or two arguments to super()","If using *args unpacking, slice to the first two elements: super(*args[:2])","Review the call site for accidental extra positional args"],"exampleFix":"# before\nsuper(*args)          # args has 3 items\n# after\nsuper(*args[:2])      # or super(args[0], args[1])","handlingStrategy":"validation","validationCode":"assert 1 <= len(call_args) <= 2, f'super() takes 1-2 args, got {len(call_args)}'","typeGuard":null,"tryCatchPattern":"try:\n    evaluate_python(code, ...)\nexcept InterpreterError as e:\n    if 'at most 2 arguments' in str(e):\n        # trim extra args and retry","preventionTips":["Count args before * unpacking into super()"],"tags":["python-executor","super","argument-count","smolagents"],"backgroundTag":"too-many-function-arguments","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}