For two decades, Bo Peep appeared to lose not only her sheep but also the number of her Hollywood rep. Last seen in a feature film in 1999’s “Toy Story 2,” the porcelain-skinned shepherd disappeared until this weekend, as the new “Toy Story 4” gives her something even better than an agent — her own feeling of agency.

No character emerges from Pixar’s “Toy Story 4” exuding a stronger sense of self than Bo (voiced by the returning Annie Potts), who has left behind the world of toy servitude to children, now fearlessly careening her way through a fairground of bright, whirring wonders — a colorful setting that could neatly symbolize Pixar’s Emeryville, Calif., headquarters.

Bo’s empowered “Toy Story 4” presence itself rises like a symbol, reflecting the contributions of leading women every creative step of the way.

Bo’s evolution to bold adventurer began, in a way, before “Toy Story 4” director Josh Cooley had even been hired at Pixar. He was fresh out of the Academy of Art in San Francisco — where he met his future wife, Erin — and living with his parents. One day, as Josh and Erin were tooling around the Bay Area, they drove past the Pixar gates.

“I had no idea they're so close,” the filmmaker recalls saying. Erin replied: “Well, you're going to work there someday.”

Cooley was initially upset — such pressure — before he weighed her words. “She was giving me hope and I was mad at her,” he recounts. “But she’s like: ‘Nope, I believe in you 100 percent.’ "

“I’m choking up thinking about it,” Cooley, 39, tells The Post. “She believed in me when I didn’t believe in myself.”

The late Pixar leader Joe Ranft recruited Cooley as an intern, and the young animator worked his way up while working on “The Incredibles,” “Cars,” “Ratatouille,” “Up” and “Inside Out.”

Once Cooley was hired to direct the fourth “Toy Story,” he was “given free rein to rethink everything,” he says. “And the one thing I couldn’t let go of was Bo Peep. I had people ask me: ‘Why is this character in the movie?’ “

He shared his tale of Erin’s early belief with the story team. From there, things began to snowball — until the studio’s code name for the entire movie became “Peep.”

Bo had been a secondary character in the first two “Toy Story” movies — Woody’s minimally developed romantic interest. She had a limited role in the action scenes, too, suggesting she was perhaps as fragile as porcelain itself.

Yet what if her path now took a dynamic turn and she shed her child ownership, becoming as confidently adventuresome within her animated world as any Disney heroine, be it Mulan or Captain Marvel? What if she boldly embraced the unsheltered “lost toy” life?

“We were having her really challenge Woody’s point of view of what a toy is, could be — that intrigued us,” says “Toy Story 4” producer Mark Nielsen. “So that, mixed with the idea of a new chapter in Woody’s development, was the thing we wrestled with — as Bo opens Woody’s eyes to a whole new purpose.”

And as Bo’s character became central to the story, an organic thing began to happen: a team of more than a dozen crew members across creative disciplines — most of them women — took shared ownership of the character. Friendships formed over their sense of mission, spanning such departments as story, character, art and animation.

Soon, throughout the studio, they became known as Team Bo.

“It became this rampant passion project,” says Becki Tower, a directing animator.

“At its core, you had opportunity to give such depth to a character who was so minimal” in the first two films, Tower says. “It was just this whole fertile ground for opportunity to give her more complexity in all the best ways.

“I think people became really attached to that opportunity to redefine her and flesh her out more,” Tower continues, “to give her more interest and more specificity and really try to make her a beautifully complex character.”

In “Toy Story 4,” Bo’s former hoop skirt becomes a cape evocative of a superhero, as she wields her staff like a martial-arts bow and drives a small vehicle with the precise abandon of a “Mad Max: Fury Road” star.

“Who is this character? The answer changed through time,”’ says directing animator Patty Kihm, also a Team Bo member. “My first interpretation was that she was like Rey from Star Wars.”

As Team Bo explored countless iterations of the character, they found a through-line of Bo’s core characteristics.

“You had this character who predominantly was only there as in relationship to Woody,” Tower says. “I think many of us now looked at her identity as it wasn’t in relation to him, but who should be on her own … and how does that play out in everything from her wardrobe to her porcelain material to how she moves to what confidence and charisma and pride and wisdom look like on-screen.

“That became this glue that sort of bonded us” as Team Bo, she said.

Now that the film is released, with millions of viewers enjoying the new Bo, the team takes pride in what she embodies.

“That idea of independence was so attractive for us as artists and creators and as independent women ourselves,” Tower says, “to be a part of that journey ourselves and to define that.”