"A competent legislature," the English journalist Walter Bagehot wrote in 1866, "is very rare." As Congress reconvenes, it needs saying that the House of Representatives proved itself in 1985 to be, far beyond anyone's expectations, a competent legislature.

It is the Democrats' last bastion in a Republican federal government, visibly out of tune with the ideas that shape public discourse. Yet it has outmaneuvered the Reagan administration and the Republican Senate and has even achieved results that can be defended as good government.

The major credit belongs to Tip O'Neill. "Fat, bloated and out of control," a freshman Republican called him and the House in 1981, and that is still O'Neill's image for many. The truth is that O'Neill is a brilliant long-range plitical strategist. Anticipating the 1982 recession, he got his Democrats on record against Reaganomics and grabbed the Social Security issue. Anticipating the 1984 recovery, he avoided confrontation with Ronald Reagan and Republicans, compromising on the budget and even Social Security so Democrats could run as incumbents in what turned out to be the No. 1 incumbent year in American political history. It is no accident that during a genuine Republican realignment, Tip O'Neill's Democrats have gained a net 11 seats in the House since Reagan won in 1980.

In 1985, when the electorate showed an increasing appreciation for competence and accomplishments, Tip O'Neill and his Democrats treated voters to a series of performances unmatched by anything from the White House or the Senate. They produced a budget resolution increasing defense and domestic spending and not raising taxes. They passed a tax reform that lowered taxes for the poor and middle-income and eliminated preferences for the well-placed and the rich. They passed an alternative to Gramm-Rudman that one- upped the Senate by beginning the cuts before the 1986 election, when 22 Republican senators are up for reelection, saving programs for the poor and taking half of its cuts from defense.

None of this was automatic. In each case likelier outcomes were chaos, division or capitulation. But each time O'Neill and his Democrats built 218-vote majorities for positive stands on tough issues. Now by standing ready to force a vote on Reagan budget cuts almost no one supports, they are set to unmask the opposition as incompetent and perhaps to force Reagan to seek the tax increase he hates.

The speaker hasn't done it alone. He has the help of some exceedingly competent legislators. Bill Gray, his choice as Budget Committee chairman, had the credentials as former Black Caucus chairman to impose discipline on the domestic budget. Dan Rostenkowski did bravura turns on tax reform at Ways and Means. The Gramm-Rudman alternative was hammered out by Thomas Foley and Richard Gephardt; and the speaker himself, cashing in on the trust he had earned from both Boll Weevils and the Black Caucus, was able to persuade all but two Democrats to endorse it.

On electoral politics, O'Neill continues to be backed up by campaign chairman Tony Coelho, who in 1981 kept the PACs from going over solidly to the Republicans and has cowed them so effectively that in 1984 Democrats got far more PAC money than Republicans for their incumbents and raised almost as much money in open seats. The Republicans may be the party of ideas. But the Democrats in the House have far more than their share of the brilliant pols.

This has the House Republicans, quite a talented bunch themselves, in a tizzy, to the point that all but 14 of them found great glee in temporarily scuttling a tax bill supported by their own president, a bill that accomplished far more of their own long- sought goals than anyone thought possible. House Republicans watch uncomfortably as Republicans everywhere else in town run things and they are left on the sidelines. They ache for an alibi -- redistricting, election-stealing, anything. The real reason is the man who, in crisis and ceremony, sits in the big chair on the podium.

Tip O'Neill has taken his defeats without flinching, and he is rewarded for his steadfastness with loyalty from his Democratic colleagues and unprecedentedly high job ratings from the public.

"Any permanent legislature at all," Bagehot wrote, "any constantly acting mechanism for enacting and repealing laws, is, though it seems to us so natural, quite contrary to the inveterate conceptions of mankind." Presented by political accident with the stewardship of a Democratic House in Ronald Reagan's Washington, O'Neill has made it a competent legislature. It is a stunning achievement. Now in his 50th year as a legislator, he seems about to take on a popular president in tune with his times in a battle for the political future.