Maxwell Smart (Steve Carell), the top analyst of the top secret American intelligence agency CONTROL, hopes to become a field agent like his idol, Agent 23 (Dwayne "The Rock" Johnson), but despite scoring extremely well in the acceptance tests Max is denied the promotion because the Chief of CONTROL (Alan Arkin) thinks Max is too valuable in his present assignment. This changes when CONTROL headquarters is attacked by their arch-enemy, the terrorist organization KAOS, led by a man known only as Siegfried (Terence Stamp). As a result, almost all of CONTROL's agents are exposed and killed. Max becomes Agent 86 and is partnered with Agent 99 (Anne Hathaway), whose recent plastic surgery has protected her identity, while former field operatives like 23 are demoted to desk jobs.Max and 99 travel to Russia on a mission to determine how KAOS has been getting nuclear weapons. Along the way, Max slowly proves to 99 that despite his inexperience and clumsiness he is actually a good field agent. Max also begins to show, as does 99, that he has slight feelings for her, and she for him. However, 99 does not want to have a relationship with any agent, as she previously blew a mission due to her being in a relationship with a partner (as it turns out, Agent 23). The pair try to infiltrate KAOS's Moscow nuclear weapons factory, which is disguised as a bakery, and even though Siegfried has been expecting them, Max and 99 overpower the guards and plant explosives that will bury the nuclear weapons under rubble. Max even saves both 99's life and his own by helping one of Siegfried's henchmen, a man named Dalip (Dalip Singh), with his marital problems using information gleaned from his analyst work. The Chief sends 23 to oversee clean-up of the bakery, but 23 reports that he has found no evidence of nuclear weapons, causing CONTROL (and an upset 99) to believe that Max is a double agent.Siegfried reveals that KAOS has distributed nuclear weapons to unstable dictators, and will supply them with the activation codes unless the American Government pays him $200 billion, and decides to establish the credibility of his threat by destroying Los Angeles with a nuclear bomb during the President's visit. The Vice-President doesn't believe CONTROL's claims that KAOS is a serious threat so the Chief, 99 and 23 go there to try and personally convince the President, to no avail. Dalip sends Max (who is in custody in Washington D.C.) a tip-off about the bomb via a radio call-in show, so Max escapes custody, equips himself with vintage items from the CONTROL museum (such as the shoe phone) and travels to Los Angeles himself to meet with the Chief and tell him about the bomb. Agent 23 doesn't believe Max's claims or his innocence because he has a crush on agent 99, even though the Chief and 99 do. This, plus the fact that Max detects trace radiation on 23 (who had walked through the Moscow nuclear facility), causes Max to realize that 23 is the double agent. 23 takes 99 hostage and flees with the bomb's remote detonator, and Max and the Chief give chase. 23 ties 99's hands tightly together and locks her in his car. Max and the Chief save 99, with Smart kissing Agent 23, which was a trick to distract him and kicks him into the now flaming, track-led government GMC Yukon. When Max and 99 are stuck to the car, Max saves 99 by throwing her to the ground while he tries to cut himself free. 99 looks up and sees the car destroyed by the oncoming train, believing Max and 23 to be killed. 99, extremely upset about Max's death, says out loud that she wished they had more time together too, an answer to a question Max asked her earlier. Suddenly, Max appears, shocking her, saying he "missed it by that much." 99 kisses Max. The three realize that the bomb, hidden in Walt Disney Concert Hall where the President is attending a concert, will be triggered when the orchestra plays the final notes of Beethoven's "Ode to Joy". Reaching the Hall just in time, Max tackles the conductor, stopping the orchestra and stopping the bomb. However, the orchestra is doubtful that there was a bomb and the guards ridicule Maxwell. Maxwell guesses correctly that the bomb was under the piano and shocks the guards. During Siegfried's escape, the terror mastermind insults Dalip once too often and Dalip throws him out of their car off a bridge and into a river.The heroes celebrate their success in CONTROL headquarters. The President is very impressed with the agency, especially Max's heroics. Max and 99 begin not-so-secretly dating and have bought a puppy, named Fang. Bruce and Lloyd get a little payback on a bullying field agent via the introduction of Hymie the Robot. The film ends with Max and 99 leaving CONTROL through the set of high-tech security doors; of course, Max can't leave the last door (which doesn't close) alone and repairs it with his pocket knife, causing the door to close on him and a mini harpoon to stick him in the cheek.
Output: Question: Who was Agent 99 previously in a relationship with?, Answer: Agent 23.