The Virginia legislature, in a move that surprised the state's lawyers and highway officials, has directed them to forgive $541,820 that the Wolf Trap Foundation for the Performing Arts had agreed to pay as its share of the cost of new sound barriers along the Dulles Toll Road.

The state's decision to force state taxpayers to cover the costs "as a bad debt" was made by a group of high-ranking legislators in early March during closed budget sessions. It was then approved by the General Assembly as part of the state's $18.6 billion biennial budget.

"It was in the wee hours, and I don't think it was explained too clearly," said state Del. V. Earl Dickinson (D-Louisa). "I certainly didn't hear anything about a half-million dollar indebtedness."

State Sen. Clive L. DuVal 2nd, a Fairfax Democrat who represents the Wolf Trap area, sponsored a budget amendment that directed the forgiveness and said in an interview that he had no apology for his action.

"It was no more sneaky than a lot of things that happen in the Secret Seven," he said, alluding to the group of senior senators who make crucial budget sessions during closed meetings. "I'm just glad I'm there to help Northern Virginia," said DuVal, who is one of the seven.

DuVal's amendment passed as state lawyers were discussing suing the foundation over its refusal to meet terms of a 1983 agreement covering additional sound barriers that were needed at the federally supported theater, which is adjacent to the state-run toll road and the federally owned Dulles Access Road.

The state budget does not refer to Wolf Trap by name. DuVal's one-sentence amendment says only that the state highway commissioner "is hereby authorized and directed to treat and write off as a bad debt any amounts associated with construction of the additional 15 feet of the noise barrier construction at or near any performing arts complex open to the general public."

Several legislators who were involved in resolving differences between the Virginia House and Senate over the budget said today they were surprised to learn that the state had agreed to forgive the Wolf Trap debt.

"It didn't pass, did it?" said state Sen. Dudley J. (Buzz) Emick (D-Botetourt). Others said they didn't realize the foundation had signed a formal contract to pay its share.

Del. Robert B. Ball Sr. (D-Henrico), a budget conferee, said, "I remember a figure, something about asking forgiveness, but they didn't say why . . . . They did not say they had a contract."

DuVal said he offered the amendment after Carol V. Harford, president of the Wolf Trap Foundation, pleaded with him last fall for help in meeting the 1983 agreement.

Under the agreement, which was also approved by the Federal Aviation Administration and National Park Service, the foundation was obligated to pay $541,820, or three-eighths of the $1.4 million costs of extending the sound barrier an extra 15 feet in an effort to reduce noise from the newly opened toll road. The Wolf Trap Park is managed by the National Park Service, and the adjoining access highway is on land owned by the FAA.

DuVal said he first sought help from Congress, writing to Sen. John W. Warner and Rep. Frank R. Wolf, both Virginia Republicans. "But obviously with the federal budget crunch on, they just disregarded" the request, DuVal said.

Del. Dorothy S. McDiarmid (D-Fairfax), chairwoman of the Virginia House Appropriations Committee and chief of the House delegation to the budget conference, said that when DuVal's amendment came up, it was not disclosed that Wolf Trap had a contract with the state. " . . . I'm sure it was brought up in the Senate," McDiarmid said. "Not a big thing was made of it."

Harford, the Wolf Trap Foundation president, could not be reached for comment, but in a letter to the state highway department last year she said that "Wolf Trap still has major fund raising responsibilities to raise its share of monies for the rebuild of the Filene Center." The center was destroyed in a fire April 4, 1982, and was rebuilt with a federal loan and private donations at a cost of $18.7 million.

In her letter, dated Sept. 26, 1985, Harford hinted to Oscar Mabry, deputy state highway commissioner, that the state should pay for the added barrier and that "we may wish to explore legislation."

Mabry's response, dated Oct. 10, said, " . . . in candor, the agreement . . . is not subject to renegotiation, amd we are extremely hopeful that means can be found to honor the $541,820 due the department under this agreement."

Assistant State Attorney General James E. Hayes said his office was "having some discussions with the highway department" over a possible lawsuit when "that course was closed to us" by the budget.

Gov. Gerald L. Baliles, who signed the budget, said he was not aware of the issue.

In a background paper to DuVal, Harford said the idea for heightening the wall came from Rep. John F. Seiberling (D-Ohio), chairman of the House subcommittee on public lands and national parks.