The U.S.-Soviet agreement yesterday to use special "centers" in each capital to exchange information on each other's military activities resulted from two years of shaky discussions that neither side approached with much enthusiasm, U.S. diplomatic and military officials said yesterday.

The agreement, signed in the White House Rose Garden by Secretary of State George P. Shultz and Soviet Foreign Minister Eduard Shevardnadze, was hailed by President Reagan as a means to build confidence in both countries' peaceful intentions and as a potential conduit for data needed to verify compliance with future arms control treaties.

But U.S. arms control officials acknowledged that the results fell far short of initial proposals by independent experts for a single Soviet-American center where officials on both sides would help defuse international crises and handle incidents of nuclear terrorism.

The impetus for the agreement is widely said to have come from Capitol Hill, where the Senate urged a reluctant Reagan administration in a 1984 resolution to pursue negotiations on "nuclear risk reduction centers" by 82 to 0. The vote resulted from lobbying by former U.S. military officials and by Sens. Sam Nunn (D-Ga.) and John W. Warner (R-Va.), senior members of the Armed Services Committee whose support on other military matters has been sought by the White House.

Reagan alluded to the legislators' role when he said the agreement resulted from "close cooperation among the executive, Congress, and private groups and individuals." Shevardnadze more directly paid "tribute to the diplomats and experts, and to the members of the U.S. Senate, particularly Sens. Nunn and Warner" who promoted the idea. Both were present at the signing ceremony.

Nunn said he became interested in the concept in 1981, when he obtained a secret study from the Strategic Air Command on the potential outcome of a single nuclear detonation on U.S. or Soviet territory at the height of an international crisis. The study convinced him that such an incident, either from terrorism or accident, was likely to cause a general nuclear war, and that the way to prevent that was to establish a forum where officials could avert misunderstanding.

Warner has said he became interested in "risk reduction centers" because of his experience as secretary of the Navy in 1972, when he negotiated an agreement to avert incidents between U.S. and Soviet ships caused by accident or miscalculation on the high seas. Ultimately, the idea was endorsed by former national security adviser Brent Scowcroft, former National Security Agency director Bobby R. Inman, and former defense secretary James R. Schlesinger.

But the Defense Department rejected the notion of a single center, staffed by senior officials from both countries, partly on the grounds that it would constrain U.S. "flexibility" by creating an unavoidable forum for continuous talks with the Soviets. Senior Pentagon officials also were concerned that the Soviets would use it to sow false information, or learn sensitive details of U.S. military activities.

Similar concerns were expressed by Soviet military officials when formal discussions began last year, U.S. officials said. The U.S. delegation was headed by Richard N. Perle, then assistant secretary of defense for international security, and by Air Force Col. Robert Linhard, a senior arms control adviser on the National Security Council staff, while the Soviet team was headed by deputy chief arms negotiator Alexei Obukhov.

The agreement does not provide for discussions between the "centers" on incidents or threats of nuclear terrorism, on nuclear proliferation, on military doctrines, or on international crises, as the Senate recommended.

Instead, it provides only for notifications through the "centers" of ballistic missile launches, as provided for by earlier U.S.-Soviet agreements, and for transmission through high-speed satellite communications of other, unspecified information intended "as a display of good will and with a view to building confidence."

A White House statement accompanying the agreement said the "centers are not intended to supplant existing channels of communications or have a crisis-management role." Although details have not yet been ironed out in the administration, the U.S. "center" is expected to consist only of a room or two at the Pentagon or the State Department with a staff of perhaps a dozen people.

As such, it will complement the "hot line" direct communications links between Moscow and Washington established in 1962 after the Cuban missile crisis. It also may complement a U.S.-Soviet expert committee that meets periodically in Geneva to discuss mutual compliance with arms control treaties.

Nunn and Warner indicated yesterday that they saw the agreement as an important foot in the door. "As we and the Soviets gain experience . . . I would expect the centers to take on additional functions, especially in the area of preventing nuclear terrorism," Nunn said.