SANTA CLARA (CBS SF) — Going into the NFL Draft there were two glaring needs for the San Francisco 49ers with the departure of veteran wide receiver Emmanuel Sanders to free agency and the trade of star defensive lineman Deforest Buckner to the Indianapolis Colts.

But there was another drama just as impactful playing out behind the scenes.

READ MORE: Oakland Unveils Environmental Impact Report On A's Howard Terminal Stadium Project

Offensive line stalwart Joe Staley was dealing with all the physical impacts a lengthy NFL career brings with it. Would he decide that it was time to step away or would he try to hang on for one more season?

On Saturday, Staley announced he was calling it a career.

“I had talked to Joe’s agent and representation Ryan Tollner,” said 49ers GM John Lynch when asked about when he knew Staley would not be returning. “I talked with him when Joe was still in the midst of making a decision. They had indicated Joe was really struggling. Where we were encouraged, was that we felt like time was on his side with no offseason program, the opportunity to get further away from a season and have that body heal. After I spoke, and I don’t know if it was the impetus, Joe will have to tell you. What I had told Ryan Tollner is, ‘Listen, at some point Joe needs to get on the phone with us and tell us where he’s at,’ and Joe did that.”

Lynch then went to work and pulled off a major deal, swinging a trade with the Washington Redskins to acquire veteran Pro Bowl offensive tackle Trent Williams for a pair of late round draft picks.

San Francisco also swapped places in the first round with Tampa Bay, picking up another late round draft pick in the deal.

“We appreciate that before the draft he let us know so that we could act on Trent Williams, but yes at 13 when we ultimately picked at 14, we did know of Joe’s decision at that point,” Lynch said.

Head coach Kyle Shanahan echoed Lynch’s sentiment.

READ MORE: Twitter Announces 'Super Follows,' Will Let Users Charge Followers To See Premium Posts

“A couple of days right before the draft, when you talk about it, knowing the tackles that could have been there available at 13, having someone available like Trent, we wanted make sure with Joe,” Shanahan said. “We thought he was going to come back and we were holding out hope, but we knew it was real early with the decision.”

“When I called him up a couple days before the draft and just asked him if he had any idea where he was at and Joe was very confident where he was at and you could tell that he wanted to retire. It was very cool of Joe to be that honest with us before the draft, because that allowed John and I to really think about it and see if any of those tackles were going to become available.”

The 49ers did not let Staley’s plan creep any doubt in their pre-draft plans that already were in place.

“We had a plan for a while going into this,” the 49ers head coach said. “You try your hardest not to panic and adjust that plan, but when you lose a guy like Joe, there is a huge panic there. We couldn’t guarantee it was going to work out with Washington, but John was as persistent as he could be with it and we took that risk.”

San Francisco was able to take South Carolina star defensive tackle Javon Kinlaw with one first round pick to replace Buckner and then took Brandon Aiyuk of Arizona State with the 25th pick to replace Sanders.

As further insurance, the 49ers also traded running back Matt Breida to the Miami Dolphins for a fifth round pick and selected West Virginia offensive tackle Colton McKivitz.

“We were able to add those other guys,” Shanahan said. “We didn’t have to go in a direction that we didn’t plan. We went in a direction that we kind of planned since the beginning and when it was said and done, the deal did work. John got it done and I think it was a good gamble that worked out well.”

As for Staley, he remained a team player to the very end.

MORE NEWS: Decision Ending Ban On High-Capacity Magazines Back Before 9th Circuit

“While I am sad and disappointed my time has come to step away, I leave with my head held high, knowing I gave my all to the game,” he posted on social media. “I fulfilled the dreams I had as a kid. Now, I will turn my attention to my daughters cultivate and achieve dreams of their own.”