In order to assure mutuality of remedy with respect to contractually authorized attorney fees, Civil Code section 1717 (hereafter section 1717) creates a reciprocal right to such fees whenever an attorney fees clause benefits fewer than all of the parties involved in litigation over a contract containing such a clause. (§ 1717, subd. (a).) By its own terms, however, section 1717 does not permit recovery of attorney fees for the defense of an action that is voluntarily dismissed prior to trial. (§ 1717, subd. (b)(2).) The question we must decide today is this: Where, as here, a contract contains an attorney fees clause that is fully reciprocal in nature, does section 1717 defeat the prevailing parties’ contractual right to recover attorney fees when the action arising out of that contract has been voluntarily dismissed? Although the majority respond to this question in mixed fashion, I believe the answer simply is no.
To clarify my position, I concur with the majority’s conclusion that section 1717 does not defeat defendants’ contractual right to recover attorney fees incurred in the litigation of plaintiffs’ voluntarily dismissed tort causes of action. However, I conclude that section also presents no obstacle to defendants’ recovery of fees with respect to the voluntarily dismissed contract claim. Indeed, as I shall explain, an entirely different set of statutes governs here because both sides to the instant litigation are bound by a mutually beneficial or “bilateral” fee clause.
In California, the Legislature has long sanctioned the right of parties to contract for the recovery of attorney fees in the event of litigation. (Code Civ. Proc., § 1021, enacted 1872.) In 1990, legislation was enacted specifying that contractually authorized attorney fees “are allowable as costs” under *625Code of Civil Procedure section 1032. (Code Civ. Proc., § 1033.5, subd. (a)(10)(A), as amended by Stats. 1990, ch. 804, § 1, p. 3551.) Under Code of Civil Procedure section 1032, a “prevailing party” is ordinarily entitled “as a matter of right” to recover costs in any action. (Code Civ. Proc., § 1032, subd. (b).) As defined by that statute, a prevailing party includes, inter alia, “a defendant in whose favor a dismissal is entered.” (Code Civ. Proc., § 1032, subd. (a)(4).)
In the case before us, plaintiffs and defendants entered into a real estate purchase agreement that contained a reciprocal provision for attorney fees broadly covering both contract and tort claims. When plaintiffs discovered defects in the real estate they purchased from defendants, they filed a complaint that alleged both contract and tort causes of action. After discovery but before any trial, plaintiffs chose to voluntarily dismiss their action with prejudice.
As the majority correctly observe, defendants are entitled to recover their attorney fees as costs both under Code of Civil Procedure sections 1021, 1032 and 1033.5, and under the terms of their agreement with plaintiffs. (Maj. opn., ante, at pp. 606-609.) However, the majority determine that section 1717 bars the recovery of attorney fees incurred in the defense of the voluntarily dismissed contract claim. I disagree. The language and legislative histories of the relevant statutes make clear that section 1717 has no application in the instant case.
Code of Civil Procedure section 1021 is unambiguous in stating that “Except as attorney’s fees are specifically provided for by statute, the measure and mode of compensation of attorneys and counselors at law is left to the agreement, express or implied, of the parties . . . .” As the majority apparently agree (maj. opn., ante, at p. 607, fn. 4), this statute evinces a legislative intent that attorney fees incurred in prosecuting or defending an action ordinarily are not recoverable as costs unless authorized by statute or by the parties’ agreement. (Reynolds Metals Co. v. Alperson (1979) 25 Cal.3d 124, 127 [158 Cal.Rptr. 1, 599 P.2d 83].)
Prior to the enactment of section 1717, not all parties who prevailed in actions over contracts with attorney fees clauses could assert a contractual right to recover such fees. For instance, many contracts contained so-called “unilateral” fee clauses that provided the right to attorney fees to one party but not to the other. Concerned that parties not having the benefit of such clauses were at a serious disadvantage in litigation, the Legislature enacted section 1717 to establish “ ‘mutuality of remedy’ ” and to prevent “ ‘oppressive use of one-sided attorney’s fees provisions.’ ” (Hsu v. Abbara (1995) 9 *626Cal.4th 863, 870 [39 Cal.Rptr.2d 824, 891 P.2d 804]; Reynolds Metals Co. v. Alperson, supra, 25 Cal.3d at p. 128; see generally, Review of Selected 1968 Code Legislation (Cont.Ed.Bar 1968) p. 35.)
As originally enacted in 1968, section 1717 provided in relevant part: “In any action on a contract, where such contract specifically provides that attorney’s fees and costs, which are incurred to enforce the provisions of such contract, shall be awarded to one of the parties, the prevailing party, whether he is the party specified in the contract or not, shall be entitled to reasonable attorney’s fees in addition to costs and necessary disbursements. . . .” (Stats. 1968, ch. 266, § 1, p. 578.) As interpreted by case law, the statute áccomplished several purposes. First, it created a reciprocal right to attorney fees when the contract at issue contained a unilateral fee clause. (See International Industries, Inc. v. Olen (1978) 21 Cal.3d 218, 223 [145 Cal.Rptr. 691, 577 P.2d 1031] (hereafter Olen).) Second, it permitted recovery of attorney fees when a nonsignatory to a contract prevailed in defending a contract action, if the plaintiff would have been contractually entitled to attorney fees had it prevailed in enforcing the contract. (Reynolds Metal Co. v. Alperson, supra, 25 Cal.3d at p. 128.) Third, it provided a procedural mechanism by which parties to either unilateral or bilateral attorney fee agreements were allowed to recover their attorney fees as items of costs rather than as special damages. (Beneficial Standard Properties, Inc. v. Scharps (1977) 67 Cal.App.3d 227, 231-232 [136 Cal.Rptr. 549] [bilateral provisions]; T.E.D. Bearing Co. v. Walter E. Heller & Co. (1974) 38 Cal.App.3d 59 [112 Cal.Rptr. 910] [unilateral provisions]; contra, Mabee v. Nurseryland Garden Centers, Inc. (1979) 88 Cal.App.3d 420 [152 Cal.Rptr. 31].)
In 1981, the Legislature amended section 1717. As pertinent here, the statute was divided into subdivisions and the substance of the language quoted above was placed in subdivision (a). Consistent with the case law cited above, subdivision (a) provided in express terms: “In any action on a contract, where the contract specifically provides that attorney’s fees and costs, which are incurred to enforce the provisions of that contract, shall be awarded either to one of the parties or to the prevailing party, then the party who is determined to be the prevailing party, whether he or she is the party specified in the contract or not, shall be entitled to reasonable attorney’s fees in addition to costs and necessary disbursements. . . .” (Stats. 1981, ch. 888, § 1, p. 3399.) Substantially similar language appears in the current version of the statute.1 Although, as I mentioned previously and will later explain more fully, prevailing parties subject to bilateral fee agreements may *627now proceed under. Code of Civil Procedure sections 1032 and 1033.5 to recover their contractual fees as costs, section 1717 remains vital for purposes of assuring mutuality of remedy for parties litigating under one-sided fee agreements.
Subdivision (b)(2) was also added to section 1717 in 1981. The relevant portion of that provision, which has remained unchanged to this day, reads: “Where an action has been voluntarily dismissed . . . , there shall be no prevailing party for purposes of this section. . . .” (Italics added.) Thus, when a party relies upon section 1717 to establish a reciprocal right to attorney fees, the restriction set forth in subdivision (b)(2) will preclude recovery if the action has been voluntarily dismissed prior to trial. Conversely, when the contract itself establishes mutuality of remedy for all parties to an action on the contract, the restriction has no application and the “measure and mode of compensation of attorneys ... is left to the agreement ... of the parties.” (Code Civ. Proc., § 1021.)
Even though section 1717, subdivision (b)(2), by its own terms specifies a restrictive definition of the term “prevailing party” strictly “for purposes of th[at] section” (italics added), the majority proceed to find such definition controlling whether or not resort to section 1717’s reciprocity provisions is necessary to extend the benefit of an attorney fees clause to all of the parties to an action on a contract. To support such widespread application of subdivision (b)(2)’s bar, the majority rely in part upon the 1981 legislative amendment to subdivision (a) that revised its language to expressly provide that the party who is determined to be the prevailing party “shall be entitled to reasonable attorney’s fees” in addition to other costs where the contract specifically provides that such fees and costs shall be awarded “either to one of the parties or to the prevailing party . . . whether he or she is the party specified in the contract or not.” (§ 1717, subd. (a), italics added, as amended by Stats. 1981, ch. 888, § 1, p. 3399.) But while that language establishes in clear terms that attorney fees may be claimed as costs by any party, including a nonsignatory, who prevails in a contract action where the contract contains either a unilateral or a bilateral fee provision, it falls far short of suggesting that subdivision (b)(2)’s voluntary dismissal provision shall apply even when the claim for fees is not dependent upon the statute.
In an attempt to bolster their expansive reading of section 1717, the majority reach back to our 1978 decision in Olen, supra, 21 Cal.3d 218, to *628determine the meaning and scope of the voluntary dismissal provision.2 (Maj. opn., ante, at p. 616.) Emphasizing Olen’s conclusion that “concern for the efficient and equitable administration of justice requires that the parties in pretrial dismissal cases be left to bear their own attorney fees, whether [the] claim is asserted on the basis of the contract or section 1717’s reciprocal right’ (Olen, supra, 21 Cal.3d at p. 225, italics added), the majority perceive Olen as holding that, with respect to attorney fees incurred in litigation over contract claims, the voluntary dismissal bar extends both to fee claims based on section 1717 and to contractual fee claims that are independent of the provisions of section 1717. (Maj. opn., ante, at pp. 615-616.)
In Honey Baked Hams, Inc. v. Dickens (1995) 37 Cal.App.4th 421 [43 Cal.Rptr.2d 595] (hereafter Dickens), the Court of Appeal exposed the flaw in the foregoing reasoning. As Dickens pointed out, Olen involved a situation in which the party seeking attorney fees had to rely exclusively on section 1717 because the contract at issue contained a nonreciprocal attorney fee provision in favor of the other party. (Dickens, supra, 37 Cal.App.4th at p. 426; see Olen, supra, 21 Cal.3d at pp. 220, 222.) At the time Olen was decided, section 1717 did not expressly provide there would be no prevailing party in cases of voluntary dismissal; instead it simply defined the term “prevailing party” to mean “the party in whose favor final judgment is rendered.” (Stats. 1968, ch. 266, § 1, p. 578.) Relying on public policy and equitable considerations, Olen held that a defendant is not entitled under section 1717 to attorney fees as a prevailing party when the plaintiff has voluntarily dismissed its action prior to trial.
As Dickens explained, while it is true that Olen discussed claims for contractual fees that were not substantively dependent upon section 1717’s reciprocity provisions, such discussion was limited to observing that the enactment of section 1717 removed a previously existing procedural bat to recovery of attorney fees as costs following a plaintiff’s pretrial dismissal. (Dickens, supra, 37 Cal.App.4th at p. 427; see Olen, supra, 21 Cal.3d at p. 223.) On that point, Olen appears to have been commenting on the fact that fairly recent case law had established that parties to contracts containing unilateral or bilateral attorney fee provisions could recover such fees either as special damages or as items of costs pursuant to section 1717. (See Olen, supra, 21 Cal.3d at p. 223, citing T.E.D. Bearing Co. v. Walter E. Heller & Co., supra, 38 Cal.App.3d 59 [unilateral provisions]; see also Beneficial Standard Properties, Inc. v. Scharps, supra, 67 Cal.App.3d at pp. 231-232 [bilateral provisions].)
*629Putting the discussion into proper perspective, it is evident that when Olen purported to conclude that concern for efficiency and equity “requires that the parties in pretrial dismissal cases be left to bear their own attorney fees, whether \thé\ claim is asserted on the basis of the contract or section 1717’s reciprocal right” (21 Cal.3d at p. 225, italics added), it was simply determining “that neither a defendant seeking substantive entitlement to fees by virtue of section 1717’s reciprocity provisions nor a defendant claiming contractual fees who invoked section 1717’s procedure could recover these fees as costs following a pretrial dismissal by the plaintiff.” (Dickens, supra, 37 Cal.App.4th at pp. 427-428; see also Kelley v. Bredelis (1996) 45 Cal.App.4th 1819, 1828-1829 [53 Cal.Rptr.2d 536].) In other words, Olen’s bar on the recovery of attorney fees was limited to defendants relying either substantively or procedurally on section 1717’s provisions to enforce a claim for attorney fees. (Dickens, supra, 37 Cal.App.4th at p. 428.) Accordingly, to the extent the Legislature intended to codify Olen by adding subdivision (b)(2) to section 1717 in 1981 (see Hsu v. Abbara, supra, 9 Cal.4th at p. 873), “this is all the limitation in subdivision (b)(2) embraces.” (Dickens, supra, 37 Cal.App.4th at p. 428, original italics; Kelley v. Bredelis, supra, 45 Cal.App.4th at p. 1829.)
These narrower readings of Olen and section 1717 are supported by the latter’s legislative history. In particular, legislative documents confirm that section 1717 was amended in 1981 in part to codify Beneficial Standard Properties, Inc. v. Scharps, supra, 67 Cal.App.3d 227, which held that section 1717 provided an option for parties to bilateral fee agreements to recover attorney fees as costs instead of as special damages, and to effectively overrule other cases, such as Mabee v. Nurseryland Garden Centers, Inc., supra, 88 Cal.App.3d 420, which held that section 1717 did not authorize the recovery of attorney fees as costs when a bilateral fee agreement was at issue. (See Sen. Republican Caucus, analysis of Sen. Bill No. 1028 (1981-1982 Reg. Sess.) as amended Aug. 24, 1981, pp. 1-2; Sen. Com. on Judiciary, Rep. on Sen. Bill No. 1028 (1981-1982 Reg. Sess.) as introduced, p. 2; Sen. Democratic Caucus, analysis of Sen. Bill No. 1028 (1981-1982 Reg. Sess.) p. 1.)
Notably, nothing in section 1717’s legislative history indicates that a purpose of the 1981 amendments was to make that section the exclusive basis for the recovery of contractual attorney fees. Likewise, none of the legislative analyses prepared in connection with the 1981 amendments suggests that the prohibition set forth at subdivision (b)(2) was intended to apply to fee claims that were neither substantively nor procedurally based upon section 1717’s provisions. To the contrary, the language of the statute is quite explicit in stating there are no prevailing parties after a pretrial *630dismissal “for purposes of this section.” (§ 1717, subd. (b)(2), italics added; Dickens, supra, 37 Cal.App.4th at p. 428.)
Legislative action since 1981 has eliminated any doubt that parties bound by fully reciprocal attorney fee agreements are entitled to recover their attorney fees as costs after pretrial dismissals. As originally enacted in 1986, Code of Civil Procedure section 1033.5 allowed recovery of attorney fees as costs only when “authorized by statute.” (Code Civ. Proc., § 1033.5, subd. (a)(10), as added by Stats. 1986, ch. 377, § 13, p. 1580.) In 1990, that statute was amended to provide that attorney fees are allowable as costs under Code of Civil Procedure section 1032 when authorized by either statute or contract. (Code Civ. Proc., § 1033.5, subd. (a)(10), as amended by Stats. 1990, ch. 804, § 1, p. 3551.) Code of Civil Procedure section 1032, in turn, specifies that a prevailing party—explicitly defined as including “a defendant in whose favor a dismissal is entered”:—is entitled “as a matter of right” to recover its costs except as otherwise expressly provided by statute. (Code Civ. Proc., § 1032, subds. (a)(4), (b).) Consequently, parties who have agreed to mutually beneficial fee agreements may now proceed under Code of Civil Procedure sections 1033.5 and 1032 to recover their attorney fees as costs following voluntary dismissals.
Code of Civil Procedure section 1033.5 was amended in other ways which confirm that section 1717 does not govern all contractual fee claims. In addition to the revision mentioned above, the statute was amended to specify that attorney fees authorized by contract are costs that shall be fixed either upon noticed motion or upon entry of a default judgment, unless otherwise stipulated by the parties. (Code Civ. Proc., § 1033.5, subd. (c)(5), as amended by Stats. 1990, ch. 804, § 1, p. 3552.) At the same time, the statute was revised to provide that attorney fees awarded pursuant to section 1717 shall be fixed in the same manner applicable to contractually authorized fees. (Code Civ. Proc., § 1033.5, subd. (c)(5), as amended by Stats. 1990, ch. 804, § 1, p. 3552.) In passing these amendments, the Legislature declared its intent to clarify the “great uncertainty as to the procedure to be followed in awarding attorney’s fees where entitlement thereto is provided by contract to the prevailing party.” (Stats. 1990, ch. 804, § 2, p. 3552.) As recognized in Dickens, supra, 37 Cal.App.4th at page 429, there would have been no need for the Legislature to include separate provisions “clarifying” application of the same procedure for both contract-based attorney fee claims and section 1717 attorney fee claims if all contract-based fee claims were necessarily subject to the provisions of section 1717.
On a final note, the majority fret that preserving a separate contractual right to recover fees that is not governed by section 1717 “would, in *631voluntary dismissal cases, defeat the underlying purpose of section 1717 to assure mutuality of remedy for attorney fee claims based on contractual attorney fee provisions.” (Maj. opn., ante, at p. 616.) However, as the majority’s analysis on the issue of tort litigation fees confirms, section 1717 was never intended to guarantee mutuality of remedy in every action involving a contractual fee provision. In any event, recognizing that section 1717 does not affect the contractual rights of parties who are bound by mutually beneficial attorney fee clauses clearly would be consistent with section 1717’s central purpose to assure mutuality of remedy.
To summarize, after plaintiffs in this case voluntarily dismissed their complaint, defendants became entitled to recover all of their contractually authorized attorney fees as costs under the terms of their agreement and under Code of Civil Procedure sections 1021, 1032 and 1033.5. Section 1717—which now functions primarily to establish mutuality of remedy when ordinary application of contract principles would otherwise preclude parties prevailing in contract actions from recovering their attorney fees— simply has no bearing where, as here, the parties are already contractually bound by a fully reciprocal fee clause. In holding that section 1717 bars the recovery of attorney fees for parties who have willingly agreed amongst themselves to evenhanded availability of fees in cases of voluntary dismissal, the majority not only frustrate the right of parties to contract for such fees (Code Civ. Proc., § 1021) but also defeat the Legislature’s clearly expressed intent that “a defendant in whose favor a dismissal is entered” (Code Civ. Proc., § 1032, subd. (a)(4)) is entitled “as a matter of right” (Code Civ. Proc., § 1032, subd. (b)) to recover its contractually authorized attorney fees as costs (Code Civ. Proc., § 1033.5, subd. (a)(10)(A)).
I would affirm the judgment of the Court of Appeal.
Werdegar, J., and Brown, J., concurred.
As it currently reads, subdivision (a) of section 1717 provides in relevant part: “In any action on a contract, where the contract specifically provides that attorney’s fees and costs, *627which are incurred to enforce that contract, shall be awarded either to one of the parties or to the prevailing party, then the party who is determined to be the party prevailing on the contract, whether he or she is the party specified in the contract or not, shall be entitled to reasonable attorney’s fees in addition to other costs. . . .” (Stats. 1987, ch. 1080, § 1, p. 3648.)
The Legislature’s addition of subdivision (b)(2) to section 1717 in 1981 is viewed as a codification of our holding in Olen, supra, 21 Cal.3d 218. (See Hsu v. Abbara, supra, 9 Cal.4th at p. 873.)