
244 Kan. 283 (1989)
767 P.2d 1302
STATE OF KANSAS, Appellant,
v.
RICHARD A. SMITH, Appellee.
No. 61,815
Supreme Court of Kansas.
Opinion filed January 20, 1989.
John H. Taylor, assistant county attorney, argued the cause, and Robert T. Stephan, attorney general, was with him on the brief for appellant.
Steven R. Zinn, supervising attorney, Kansas Appellate Practice Clinic, of Lawrence, argued the cause, and Joan Gummels, legal intern, and Benjamin C. Wood, chief appellant defender, of Topeka, were with him on the brief for the appellee.
The opinion of the court was delivered by
MILLER, C.J.:
The defendant, Richard A. Smith, was charged in the district court of Geary County with delivery of cocaine, a felony, in violation of K.S.A. 65-4127a. The trial court dismissed the case, holding that this prosecution was barred by the terms of a plea agreement which the State and Smith had entered into in an earlier and unrelated case. The State appeals.
The State has briefed two issues. It contends that the trial court abused its discretion in ruling that this prosecution was barred by the terms of the plea agreement, and that the trial court erred in construing the plea agreement. Since we conclude that the trial court erred in its construction of the plea agreement, we reverse without reaching the abuse of discretion argument.
The facts are undisputed and we shall attempt to give them in chronological order. On April 16, 1987, a federal undercover agent bought a quarter gram of cocaine from a man he knew only as "Smitty." Later that month, he reported this activity to Roger Williams, a Junction City police narcotics investigator. Williams knew the defendant, Richard Allen Smith, but did not know him as "Smitty." The defendant's photograph appeared in "mug" books of the Junction City Police Department in April 1987, but the federal agent did not review the books, and did not make an identification of the person from whom he made the narcotics purchase until several months later.
The defendant entered into a plea agreement with the State on *284 July 13, 1987, in a consolidated proceeding involving three earlier cases in which he was charged with theft by force, forgery, and theft. The plea agreement, signed by the defendant, his attorney, and an assistant Geary County Attorney, contains the following language which lies at the heart of this appeal: "The State agrees [not] to file any other charges against the defendant based upon information presently known or which should be known by the Geary County Attorney's office." (Emphasis supplied.) The plea agreement was approved by the trial court. Defendant's pleas of guilty to all three charged crimes were accepted and sentence was imposed pursuant to the plea agreement.
Thereafter, on August 18, 1987, the federal agent, while reviewing the Junction City "mug" books in connection with another matter, came across defendant's photograph and identified him as the "Smitty" from whom he had purchased cocaine in April. This prosecution was commenced on September 8, 1987, based upon information furnished by the federal agent, and the identification made by him on August 18. It is undisputed that at the time the plea agreement was entered into, the Geary County Attorney's Office had no actual knowledge of defendant's alleged sale of cocaine in April. The issue then is whether, at the time it entered into the plea agreement, the county attorney's office should have known of the facts upon which this prosecution is based.
Several rules which govern the interpretation of written contracts are relevant here. The interpretation of a written contract which is unambiguous is a judicial function. Wood River Pipeline Co. v. Willbros Energy Services Co., 241 Kan. 580, 582, 738 P.2d 866 (1987). In that same case, we noted that the intent of the parties and the meaning of a contract are to be determined from the plain, general, and common meaning of terms used. Also, in City of Arkansas City v. Anderson, 242 Kan. 875, Syl. ¶ 1, 752 P.2d 673 (1988), in Willbros, 241 Kan. at 586, and in Patrons Mut. Ins. Ass'n v. Harmon, 240 Kan. 707, Syl. ¶ 1, 732 P.2d 741 (1987), we stated and followed the familiar rule that, regardless of the construction given a written contract by the trial court, an appellate court may construe a written contract and determine its legal effect. See Kennedy & Mitchell, Inc. v. Anadarko Prod. Co., 243 Kan. 130, Syl. ¶ 1, 754 P.2d 803 (1988).
*285 Is contract law helpful and properly applied in construing a plea agreement which was entered into in a criminal proceeding? We think so. Our research discloses that this proposition has widespread support. In United States v. Ocanas, 628 F.2d 353, 358 (5th Cir.1980), cert. denied 451 U.S. 984 (1981), the court concluded that while principles of contract law cannot be blindly incorporated into the area of plea bargaining, they provide a useful analytical framework. In United States v. Calabrese, 645 F.2d 1379, 1390 (10th Cir.1981), the court said: "Courts have frequently looked to contract law analogies in determining the rights of defendants aggrieved in the plea negotiation process. See Cooper v. United States, 594 F.2d 12, 15-16 (4th Cir.1979); Westen & Westin, A Constitutional Law of Remedies for Broken Plea Bargains, 66 Cal. L. Rev. 471, 530 (1978)." Similarly, in Cooper v. United States, 594 F.2d at 16, the court commented: "To the extent ... that there has evolved any general body of `plea bargain law,' it is heavily freighted with ... contract law analogies."
Finally, in Note, The Standard of Proof Necessary to Establish that a Defendant Has Materially Breached a Plea Agreement, 55 Fordham L. Rev. 1059, 1065-67 (1987), the author states:
"Although a plea bargain is essentially a contract, it is a peculiar creature of contract law. The exchange that effectuates the agreement is the defendant's guilty plea and its attendant waiver of constitutional rights. Acceptance of the guilty plea by the court validates the agreement and the waiver. A defendant who plea bargains thus has a due process interest in assuring that the state will not arbitrarily deny him the fulfillment of that agreement. Although contract law provides a framework for legal analysis of plea bargain disputes, it is an imperfect analogy.
....
"[P]lea agreements are essentially contracts to which contract law may be applied, and ... the due process clause is the source of the defendant's constitutional rights implied in plea agreements."
A question somewhat similar to the one we have before us was considered by the Oregon Court of Appeals in State v. Hammang, 19 Or. App. 265, 527 P.2d 137 (1974), aff'd 271 Or. 749, 534 P.2d 501 (1975). The Oregon Court of Appeals was considering the rule that a prosecution is prohibited by the bar on double jeopardy if the prosecutor knew or reasonably should have known of facts relevant to the second charge at the time of the original prosecution. The court held that "should have *286 known" means only that a reasonably diligent prosecutor would have acquired actual knowledge of the additional crime. The court went on to hold that there was no basis for concluding that greater diligence on the part of the prosecution would have brought additional evidence to light at the time defendant entered his plea to the crime first charged, theft of firearms. Most of the witnesses to the murder had promptly fled from the jurisdiction; only later, after defendant's theft plea, did the police locate and interview two of the witnesses, whose testimony indicated for the first time that defendant participated in the homicide, the crime with which he was subsequently charged. The Oregon Court of Appeals agreed with the trial court's holding that the prosecution neither knew nor should have known, at the time defendant pled guilty to the theft charge, that he had previously participated in the murder. The firearm that Hammang was convicted of stealing in the first case was used, on the day it was stolen, to commit the homicide charged in the second case. Although the prosecution was aware of several facts connecting Hammang to the chain of events leading up to the homicide, the court concluded that the prosecution neither knew nor should have known that Hammang was involved in the homicide when the plea to the firearms charge was entered.
In a later case, State v. Knowles, 289 Or. 813, 618 P.2d 1245 (1980), an Oregon State Police Officer came upon the defendant in possession of both an elk and a deer. The officer issued defendant a uniform citation for possession of the elk, but did not cite him for possession of the deer, a more serious offense, since he wished to consult with his superior officer before charging possession of a deer. The defendant appeared promptly in court and pled guilty to the elk offense. Approximately a month later, the officer swore out a felony complaint charging possession of the deer. On defendant's motion, the latter charge was dismissed by the trial court. On appeal, the Oregon Supreme Court held that there was no evidence that the district attorney had actual knowledge of the various offenses when defendant entered his plea to the elk charge, nor was there evidence that the prosecutor "reasonably" knew of the offense concerning the deer at the time of the elk prosecution. The decision of the lower court was reversed and the case remanded for further proceedings. See State v. Anthony, 68 Or. App. 718, 683 P.2d 559 (1984).
*287 A slightly different problem faced the Texas Court of Criminal Appeals in Joiner v. State, 578 S.W.2d 739 (Tex. Crim. 1979). There, Joiner had pled guilty to a charge of possession of heroin on July 3, 1976. The plea agreement in that case provided the prosecutor would drop all charges then "pending" against the accused. Some three months later, an undercover agent who had been working undercover in the county filed two charges against Joiner for delivery of heroin in May 1976. Joiner contended on appeal that the plea bargain was meant to cover offenses about which the prosecutor should have known, even though they were not officially filed, and that it was his understanding that the plea agreement would clear him of all such offenses. The Court of Criminal Appeals held that the evidence does not compel such a conclusion, and thus (in the absence of actual knowledge by the prosecutor of the earlier offense) the action of the trial court in overruling Joiner's motion was not error.
In the case now before us, the defendant filed a motion to dismiss after arraignment, alleging that the prosecution was barred by the terms of the prior plea agreement. The trial court was required to determine, upon the basis of the record before it, whether the prosecutor knew or should have known of the facts upon which this prosecution is based at the time the plea agreement was entered into. The trial judge opined, "If a crime was committed, you [the prosecutor] should know who did it, and it should be known by you if somebody commits a crime." The judge thereupon held that the language of the plea agreement was so broad as to include the crime charged in this case. He sustained the defendant's motion and dismissed the case. We disagree.
The State, by its plea agreement with Smith, specifically limited its promise of no prosecution to charges based upon information known or which should be known by the prosecutor at the time of the plea agreement. The State did not promise that it would not prosecute any and all prior crimes of the defendant, known or unknown.
It is undisputed that neither the Geary County Attorney nor any state, city, or county employee had knowledge of the alleged sale of cocaine at the time the plea agreement was entered into on July 13, 1987. The facts were known only to a federal undercover agent, an army investigator. Whether he would later be *288 able to identify the person from whom the purchase was allegedly made, whether he could or would furnish sufficient information to the state prosecutor to justify prosecution, and whether the agent would be available to appear and testify were questions which no state agent or employee could have answered when the plea agreement was entered into. True, the federal agent could have inspected the "mug" books earlier, and perhaps could have made an identification at an earlier date, but he did not. He was not under the direction and control of the Geary County Attorney's Office or any state agency. As in Hammang, there is no evidence that greater diligence on the part of the county attorney's office would have brought the prior crime to light. A county attorney is not reasonably required to know everything that all federal agents, working in his or her county, have learned. We hold that the terms of the plea agreement simply do not encompass knowledge of this offense under the facts of this case.
It is a familiar rule that when the finding of fact of a trial court is attacked on appeal for insufficiency of evidentiary support, we search the record for any substantial competent evidence which supports the finding. We have done so in this case and we find that there was no evidence before the trial court to support a finding that the county attorney or his staff knew or should have known of the crime charged here.
The judgment of the trial court is reversed and the case is remanded for further proceedings.
SIX, J., dissenting:
In my view, this criminal case concerns the trial court's discretion in the enforcement of a plea agreement. Pursuant to K.S.A. 1987 Supp. 22-3602(b)(1), the State appeals the trial court's dismissal of an information charging defendant Richard Smith with delivery of cocaine (K.S.A. 65-4127a).
The sole issue for our review should be: Did the trial court abuse its discretion in ruling that prosecution was barred by the terms of a prior plea agreement?
Following his arraignment, Smith filed a motion to dismiss, alleging that prosecution was barred by the terms of the prior plea agreement. The trial court agreed and dismissed the complaint.
The trial court ruled:

*289 "[T]he language of the plea agreement in question here is so broad as to include the present case.
"The language of the agreement is strictly construed against the County Attorney's Office."
The trial court reasoned that the agreement was ambiguous and that the ambiguity was to be construed in favor of Smith.
When a plea bargain is ambiguous, the court may examine the entire record and, based upon the facts of the case, define and apply the ambiguous phrase or term. See State v. Talsma, 2 Kan. App.2d 551, Syl. ¶ 1, 2, 584 P.2d 145 (1978).
At the hearing on Smith's motion to dismiss the September cocaine charge, the trial court heard the testimony of Investigator Roger Williams and of Steven L. Opat, the Geary County Attorney.
Williams testified that he personally knew Richard Allen Smith prior to April 1987. Smith's photograph appeared in mug books at the Junction City Police Department prior to that time. An undercover agent had access to these mug books upon request. The person described as "Smitty" in April of 1987 was later determined by the undercover agent to be Smith, the defendant. The undercover agent relayed the information about the drug buy and about "Smitty" to Williams in April of 1987. Williams stated that when a determination is made by the Junction City Police Department that legal recourse is necessary in a felony matter, the information is brought to the Geary County Attorney's Office.
By dismissing the cocaine charge, the trial court determined that Smith was entitled to specific performance of the plea agreement. A plea bargain, prior to the defendant's acceptance, is a mere "executory agreement." Mabry v. Johnson, 467 U.S. 504, 507, 81 L.Ed.2d 437, 104 S.Ct. 2543 (1984).
Once the defendant accepts the agreement by pleading guilty, due process requires that the bargain be kept. Santobello v. New York, 404 U.S. 257, 30 L.Ed.2d 427, 92 S.Ct. 495 (1971). "[W]hen a plea rests in any significant degree on a promise or agreement of the prosecutor, so that it can be said to be part of the inducement or consideration, such promise must be fulfilled." Santobello v. New York, 404 U.S. at 262.
The Santobello court suggested two possible remedies: (1) specific performance or (2) an opportunity to withdraw the plea. *290 The choice is within the discretion of the trial court. Santobello v. New York, 404 U.S. at 263. The record in this case shows that the trial court selected the first option and ordered the Geary County Attorney's Office to specifically perform. This choice bars the prosecution of Smith for delivery of cocaine.
The crux of this issue is whether the trial court abused its discretion by ruling that under the plea agreement the drug buy and Smith's role in it were matters "which should be known" to the Geary County Attorney's Office. The State drafted the subjective phrase "which should be known." Any uncertainty in its meaning should bind against the State, not against Smith. The majority holds that the phrase in question is unambiguous. I disagree. What "should be known" to a prosecutor? Any number of criminal law experts could respond to this question, but would they agree? The majority: (1) views this case as one involving the interpretation of a written contract; and (2) construes the phrase against Smith rather than against the State, the author of the ambiguity.
Smith's prosecution for delivery of cocaine relied on factual information which had been available to law enforcement agencies in Geary County prior to July 13, 1987. Nevertheless, the facts were not connected and put to use until the August 1987 identification by the undercover agent.
The majority opinion cites State v. Hammang, 19 Or. App. 265, 527 P.2d 137 (1974), aff'd 271 Or. 749, 534 P.2d 501 (1975). Hammang is a double jeopardy case. I draw upon it in support of two appellate propositions I view differently than the majority when applied to the case at bar: (1) factual determinations; and (2) scope of review. In Hammang the question was stated by the Oregon Court of Appeals to be: "Thus, our inquiry is directed to whether the prosecution knew or should have known of the facts relevant to the murder charge on August 3, 1973, the date defendant plead guilty to theft." 19 Or. App. at 268.
The Hammang court then asks the question we in Kansas are interested in: "How is this `knowledge' question to be resolved?" 19 Or. App. at 268.
Oregon answers the question:
"[T]he question of knowledge is one of fact. Being a question of fact initially passed upon by the trial court, it follows that the trial court must, if there is any factual dispute, hold an evidentiary hearing to determine the facts. And once the trial court has determined the factual question of prosecutorial knowledge, its *291 finding should be subject to only limited review in this court under the doctrine of Ball v. Gladden, 250 Or. 485, 443 P.2d 621 (1968)." 19 Or. App. at 269.
The trial judge in the case at bar held an evidentiary hearing. He listened to the testimony of Investigator Roger Williams and of the Geary County Attorney, Steven L. Opat.
The State urges this court to find that the trial court abused its discretion. "An abuse of discretion exists only when no reasonable man would take the view adopted by the trial court." State v. Carmichael, 240 Kan. 149, 157, 727 P.2d 918 (1986) (citing Wilson v. American Fidelity Ins. Co., 229 Kan. 416, 422, 625 P.2d 1117 [1981]). In my view the majority has substituted its judgment for the judgment of the trial court. Under the facts of Smith's case, the trial court did not abuse its discretion by: (1) construing the agreement against the State; (2) ordering specific performance of the prior plea agreement; and (3) dismissing the cocaine charge against Smith. I would affirm the ruling of the trial court.
HERD and ALLEGRUCCI, JJ., join the foregoing dissenting opinion.
