The story of how Teddy Kennedy agreed to appear on the podium with President Jimmy Carter last Thursday night is now leaking out in dribs and drabs.

It is a tale of all-night negotiations, frayed tempers, pleas for unity and sometimes bitter recrimination.

The negotiators met soon after Teddy's speech on Tuesday night, when the Carter people realized that if Kennedy did not appear on Thursday evening the Democratic Party would be torn asunder. Top aides from the Carter and Kennedy factions closeted themselves in a tent at Camp Waldorf on Park Avenue.

Teddy's people knew they were dealing from strength. His chief negotiator said, "Our boy is going back to Cape Cod unless he gets his $12 billion jobs program in the next budget."

Carter's top aide said, "He's got it. But he has to be in Madison Square Garden, out of sight, while the president makes his acceptance speech."

"No way," the Kennedy man said. "Teddy stays in his hotel suite until the speech is over."

"Okay, as long as he gets to the Garden before the applause for Carter starts. But we want Teddy when he arrives on the podium to embrace Carter just like Menachem Begin does all the time."

"Teddy never embraces anyone. We might let you have a handshake if Carter agrees to do away with tax shelters."

"We don't see any problem with that. But we have to have more assurance that there is party unity. We want Carter to be able to lift Teddy's arm in a victory gesture for the covers of Time and Newsweek magazines."

"It can't be done," the Kennedy negotiator said. "Teddy has tennis elbow, and it hurst him to lift his arm over his head."

"He's been lifting his arm during the entire campaign."

"He only got the tennis elbow after he decided not to put his name in for nomination."

"How about the other arm? Carter will stand on his right."

"Teddy hurt that arm sailing. Teddy doesn't want Carter lifting either of his arms."

"Would he lift it if we came out for his national health program?"

"I'll have to check that with him." The aide called Kennedy and then said to the Carter people, "Teddy would like to do it, but his doctors say he has to keep his hands in his pockets."

"You have to give us something," the Carter man pleaded. "It would look terrible if Teddy comes on the platform and keeps his hands down. What about a smile? Can we count on a big Kennedy smile when he's up there?"

The kennedy man said, "Impossible. A smile from Teddy is nonnegotiable."

"You got us up against the wall. Suppose we give Massachusetts a new naval base, three Air Force bases and a contract to build a strategic bomber."

"That's worth Teddy making a fist, but not a smile."

"So what's he going to do when he arrives on the platform?"

"He'll shake hands with Carter and Rosalynn and say hello to Amy and then wave to the crowd."

"But that will look terrible on television. We want to leave New York united. Surely Teddy can give us a little more than that. What if he kisses Amy on the cheek? That can't hurt him with his supporters."

"I'll check with him," the Kennedy man said.

The aide spoke to Teddy and hung up the phone. "Teddy says he doesn't kiss children."

"So all we've got so far," the Carter man said, "is Teddy showing up on the podium. Is that it?"

"Isn't that enough? If you don't like the terms, he can always fly out before Thursday night." $"I better check with the president." Carter's aide called up Jimmy and told him the terms. There was some back-and-forth talk and then the aide hung up. "The president said we'll agree to everything, as he feels Teddy's appearance is esential to his victory in November."

"Did you tell him Teddy wouldn't smile?"

"Yes, and Jimmy said he wasn't worried, because he'll be able to smile, enough for both of them."