It's heavily dependent on what you want to get out of it. From a resume POV, you want to show that you fully exploit the opportunities that are available to you, and yet also will seek out new opportunities if there are no more opportunities available to you. How long that translates to depends on how many opportunities are available to you.
I would say that if you're looking for technical skills, those max out at about 18 months. If you're looking to develop leadership, sales (as an engineer) or soft skills, plan on staying a minimum of 4 years, because it takes 2 years or so before people recognize that you have the technical skills to be worth listening to, and then another couple years to actually develop the soft skills. Persistence is another hard one: if you're trying to develop persistence, you need to get put on an ambitious project, and then you need to stick it out until the moonshot succeeds, which frequently takes 3ish years. Soft intrapersonal skills like recognizing your own blind spots and learning how to compensate for them are really hard: many people will never develop these skills, but if you do it usually takes being put on a project that's outside of your comfort zone, and then seeking therapy to deal with the anxiety and avoidance this creates, which usually takes all the time required to develop the skills above plus a year or so.
I would say that if you're looking for technical skills, those max out at about 18 months. If you're looking to develop leadership, sales (as an engineer) or soft skills, plan on staying a minimum of 4 years, because it takes 2 years or so before people recognize that you have the technical skills to be worth listening to, and then another couple years to actually develop the soft skills. Persistence is another hard one: if you're trying to develop persistence, you need to get put on an ambitious project, and then you need to stick it out until the moonshot succeeds, which frequently takes 3ish years. Soft intrapersonal skills like recognizing your own blind spots and learning how to compensate for them are really hard: many people will never develop these skills, but if you do it usually takes being put on a project that's outside of your comfort zone, and then seeking therapy to deal with the anxiety and avoidance this creates, which usually takes all the time required to develop the skills above plus a year or so.