Abstract
Most writing on AI agents for small firms explains what agents are and why they pay; very little shows how to build one. This paper builds one end to end for a common task: turning emailed requests for quotes into draft quotes at an illustrative 40-person metal fabricator in Vancouver. The shop's quoting procedure becomes an agent specification, nine tools served over the Model Context Protocol, written escalation rules, a short system prompt and a harness that logs every step. The design rests on one principle: the model reads the request and fills in a form, while deterministic code does every calculation and every decision a written rule can make. No tool can send, approve or discount a quote, so a misled model can at worst put a wrong draft in front of the estimator. Two rounds of independent red-team review showed why the tools that write must also check the customer, the original request and the price themselves: by changing one field, a misled model could get a draft for a request that should have been escalated, and each round of fixes narrowed that gap without closing it. The build is tested with 21 unit tests, including 16 tampering attacks, a 26-request answer key with two prompt injections and a dry run through the real tool server. Go-live gates are set for routing, escalation recall, field accuracy and price error. With realistic routing, payback lengthens from 5.6 to 8.8 months. The code is free to download.
Keywords: AI agents; small and medium-sized enterprises; quoting; Model Context Protocol; tool design; prompt injection; human in the loop; red teaming
1. Introduction
Earlier papers in this journal set out what a small or mid-sized enterprise (SME) needs before it deploys an AI agent: data, documented processes and a staged path [1], controls on identity and prompt injection [2], oversight matched to risk [3], a cost-per-task view of the economics [4], a home-made evaluation [5] and open integration standards [6]. A companion guide for owners costed a quote-request agent at a fabrication shop and found a payback of 5.6 months [7].
None of these papers shows how the agent is actually built. An owner who accepts the case still has to decide what the agent reads, which tools it gets, where the prices come from, what it must never do, how to test it and when to let it near a customer. This paper answers those questions for one agent, built in full, and publishes the code.
The task is the one costed in that guide [7]: a 40-person fabricator receives about 60 requests for quotes a week by email, and an estimator spends about 25 minutes on each. The firm, its customers and its rates are illustrative. Sections 2 to 4 go from the procedure to the built agent, Sections 5 to 7 cover guardrails, testing and go-live, and Sections 8 and 9 cover transfer and limits.
One principle runs through the build. Anthropic distinguishes workflows, in which language models and tools are orchestrated through predefined code paths, from agents, in which the model directs its own process and tool use, and advises using the simplest design that works [8]. The quote agent sits between the two: the model decides how to read a messy email and which look-ups it needs, but written rules in code fix the route, and every number comes from a calculation the model cannot change. The model reads and the code decides. The paper also reports what two rounds of independent red-team review found wrong with the build, because the failure they found is one most SME builds will share.
2. The Process Before the Agent
2.1 The shop and its quoting procedure
The illustrative shop cuts plate on a laser and a plasma table, forms parts on a press brake up to 12 mm, welds to CSA W47.1 under Canadian Welding Bureau (CWB) certification, powder coats in-house and sends parts out for hot-dip galvanizing. Its customers are marine, food equipment, mechanical and solar-racking firms around the Lower Mainland. Requests arrive in a shared quotes inbox, usually with a PDF drawing, sometimes with only a sentence.
The quoting procedure is short and, like most in small shops, only partly written down. The estimator reads the request and the drawing, looks up the customer, the material and similar past jobs, prices the part in a spreadsheet, asks the shop manager to approve anything large or unusual, and writes and sends the quote (Figure 1).
2.2 Where the 25 minutes go
Table 1 splits the estimator's 25 minutes into the steps of Figure 1 and shows which of them an agent can take on. Three of the five steps are reading, looking up and calculating, which is the work an agent with the right tools does well. The judgment steps stay with people: deciding whether an unusual job is worth taking, and sending the quote that commits the shop to a price.
| Step | Before (min) | Who does it with the agent | After (min) |
|---|---|---|---|
| Read request and drawing, list what is asked | 6 | Agent extracts a structured part spec | 0 |
| Look up customer, material and similar past jobs | 6 | Agent, through read-only tools | 0 |
| Price the part | 7 | Pricing engine (deterministic code) | 0 |
| Check large or unusual jobs with the shop manager | 2 (average) | Rules route these to the estimator | 0 for drafts |
| Review the draft, correct it and send it | 4 (write and send) | Estimator | 8 |
| Total per routine request | 25 | 8 |
Illustrative figures consistent with the worked example in [7]. The 8 minutes after the agent assume a complete draft with its assumptions listed; requests the rules send to the estimator save little (Section 7.3).
3. From SOP to Agent Specification
3.1 Mapping the procedure
A standard operating procedure (SOP) is most of an agent specification already [1]. What the agent needs in addition is precision: the exact event that starts it, the fields it must find, the systems it may read and write, and the rules that decide what happens next. Table 2 maps each element of the shop's quoting procedure to the specification the build uses.
| SOP element | Agent specification | In the reference build |
|---|---|---|
| Purpose and scope | Goal and boundaries | Draft quotes for single cut, formed, welded or finished parts; not assemblies or design advice |
| Trigger | Event that starts a run | A new message in the quotes inbox |
| Inputs | Fields to extract | 15 fields: customer, part, material, thickness, blank length, blank width, cut length, bends, weld minutes, finish, quantity, tolerance, lead time, certification, drawing present |
| Records consulted | Read tools | Request, customer account, material catalogue, past quotes, price calculation, rule check |
| Output | Write tools | Draft quote, clarification draft or hand-off to the estimator, each saved for review |
| Decision rules | Rules in code | Ten written rules (Table 5) that return draft, clarify or escalate |
| Approvals | Human-in-the-loop points | The estimator approves and sends every quote; the agent cannot send |
| Records kept | Audit trail | Every model turn and tool call logged per request |
| Performance measures | Metrics and gates | Routing accuracy, escalation recall, field accuracy, price error, acceptance rate, cost per request (Section 6) |
Author's specification for the illustrative shop.
3.2 Why the route is fixed in code
The specification could have left the model to decide when a request is too large, too rushed or too unusual to quote. It does not, for two reasons. First, those decisions are already written down, or easy to write down, as thresholds the shop manager agrees with, and code applies a threshold the same way every time. Second, a rule held in the prompt can be argued away by a cleverly worded email, while a rule held in code cannot. The model's freedom is therefore limited to what code cannot do well: reading free text and drawings written in a dozen styles and putting the result into fixed fields.
3.3 What the agent must never do
The specification lists what is out of bounds as explicitly as what is in: sending anything to a customer, approving a quote, applying a discount, changing a price list or customer record, promising a delivery date or answering a design question. Sending, approving, discounting and changing records are prevented by the absence of tools, the first mitigation OWASP gives for excessive agency [9]. Promises and advice are different: the cover note and questions are free text, so they rely on the instructions and the estimator's review.
4. Building the Agent
4.1 Architecture
Figure 2 shows the parts of the reference build. Requests arrive in an inbox. An agent runner, the harness, picks up each new request and runs the loop: it passes messages to a tool-using language model, executes the tool calls the model asks for, logs every step and makes sure each request ends with an outcome. The tools are served by an MCP server, which calls a deterministic engine for pricing, rules and look-ups over the shop's data. The server writes only to three queues that the estimator works from.
MCP is an open protocol, built on JSON-RPC 2.0 messages, through which servers offer tools, resources and prompts to AI applications [10]. Serving the tools over MCP keeps the build portable: the same server can be used by another model, a desktop assistant or a no-code builder that speaks MCP. The reference build uses the official Python SDK, version 2, in which the server class is called MCPServer [11]. Choosing between code, no-code and agents built into existing software is the subject of the next paper in this series.
4.2 The tools
The agent has nine tools, six that read and three that write (Table 3). Three design rules govern them:
- Read tools never change anything. They return data. In deployment, the ERP account behind them is read-only.
- Write tools only create drafts or queue items. Each request ends with exactly one of them, and nothing they write reaches a customer until a person sends it.
- Write tools do not trust the model's routing or its numbers. They take the customer from the email's sender, run their own checks on the original request (Section 4.4), re-apply the rules and recompute the price on the server. If the result is not the route the tool exists for, it refuses. What they cannot do is prove that every dimension the model extracted is true to the drawing; that is the estimator's check, and each draft carries the original request for it.
| Tool | Type | What it does | Guard |
|---|---|---|---|
| read_rfq | Read | Returns the email and the drawing text, labelled as untrusted customer content | Read-only inbox access; valid request IDs only |
| get_customer | Read | Looks up the account, terms and credit status in the ERP | Read-only ERP view |
| get_material | Read | Maps a grade exactly as written (A36, 316L, 5052) to a catalogue code and thickness range | Exact matches only, so "AR400, similar to A36" is not found |
| find_similar_quotes | Read | Returns up to three similar past quotes with unit price and whether they were won | Read-only |
| price_part | Read | Prices one line by Eqs. (1) to (3) and returns the breakdown | Deterministic; impossible values refused |
| check_escalation | Read | Applies the ten rules of Table 5 and the server's checks on the original request; returns draft, clarify or escalate | Customer taken from the sender |
| create_draft_quote | Write | Saves a draft quote with price breakdown, similar quotes, any price warning, the agent's assumptions and the original request | Re-runs all checks and the price; refuses unless the route is draft |
| request_clarification | Write | Saves the questions for the estimator to send | Refuses unless the route is clarify; does not send |
| route_to_estimator | Write | Hands the request over with the agent's reasons and the rules' reasons | Always allowed; records both sets of reasons |
There is no tool to send email, approve a quote, apply a discount or change a record.
Tool descriptions are written for the model, not for programmers. Anthropic's guidance is to invest as much effort in this agent-computer interface as in a human interface, and to change a tool's arguments so mistakes are harder to make [8]. Listing 1 shows two tools as they appear in the package. The description of price_part tells the model not to calculate prices itself and to convert inches first; create_draft_quote shows the checks that make the write boundary hold.
server.py4.3 The pricing engine
A language model asked to multiply a mass by a price and add a markup will usually get it right and occasionally get it wrong, with equal confidence either way. A quote is a commitment, so every number comes from code, as in the tool-grounded design proposed in this journal for OEE analysis [12]. The engine prices one line in three steps. The mass of the blank and its material cost are given by Eq. (1):
where \(\rho\) is the density (kg/m³), \(L\), \(W\) and \(t\) the blank length, width and thickness (m), \(p_{\mathrm{kg}}\) the material price per kilogram and \(s\) the scrap allowance. The cost of one part is the sum of material, cutting, bending, welding and finishing, Eq. (2):
where \(\ell_{\mathrm{cut}}\) is the cut length per part (m), \(c_{\mathrm{cut}}(t)\) the cutting cost per metre at that thickness, \(n_b\) the number of bends at \(c_b\) each, \(t_w\) the welding minutes at hourly rate \(r_w\), and \(C_{\mathrm{fin}}\) the finishing cost: powder coat priced on both faces of the blank, or galvanizing priced by mass. The lot price, Eq. (3), adds a set-up charge for each operation, applies the markup and enforces the minimum order:
where \(q\) is the quantity, \(n_{\mathrm{op}}\) the number of operations (cutting, plus bending, welding and finishing where used), \(c_{\mathrm{set}}\) the set-up charge per operation, \(C_{\mathrm{lot}}\) the top-up to the galvanizer's lot minimum, \(\max(0,\, G_{\min} - q\,C_{\mathrm{fin}})\) for galvanized parts and zero otherwise, \(k\) the markup and \(P_{\min}\) the minimum order. Table 4 gives the shop's illustrative rates.
| Rate | Value | Rate | Value |
|---|---|---|---|
| Scrap allowance \(s\) | 15% | Bend \(c_b\) | $2.75 each |
| Markup \(k\) | 30% | Welding \(r_w\) | $95/h |
| Set-up \(c_{\mathrm{set}}\) | $45 per operation | Powder coat | $28/m² |
| Minimum order \(P_{\min}\) | $250 | Galvanizing | $1.40/kg of blank mass; lot topped up to \(G_{\min}\) = $150 |
| Cutting, carbon steel | $1.10/m to 3 mm; $1.60 to 6 mm; $2.60 to 10 mm; $4.20 to 16 mm; $7.50 to 25 mm | Cutting factor | ×1.4 stainless; ×1.2 aluminum |
| 44W carbon steel | $1.65/kg | 304 / 316 stainless | $6.20 / $7.90 per kg |
| 5052 / 6061 aluminum | $7.40 / $7.10 per kg | Densities \(\rho\) | 7850 carbon; 7930 / 7980 stainless; 2680 / 2700 aluminum (kg/m³) |
| Press brake | Bending up to 12 mm | Sheet and plate size | Blanks up to 3000 × 1500 mm |
Illustrative values for the fictional shop, set for this paper; they are not market prices. Replace them with your own before using the engine.
Worked example. Request RFQ-001 asks for 50 mounting brackets in 6 mm 44W steel, blank 200 × 150 mm, 0.9 m of cutting, two bends, powder coated. Eq. (1) gives \(m = 7850 \times 0.200 \times 0.150 \times 0.006 = 1.413\) kg and \(C_{\mathrm{mat}} = 1.413 \times 1.65 \times 1.15 = \$2.681\). Eq. (2) adds cutting \(0.9 \times 1.60 = \$1.44\), bending \(2 \times 2.75 = \$5.50\) and powder coat \(2 \times 0.200 \times 0.150 \times 28 = \$1.68\), so \(c_u = \$11.301\). Three operations add \(3 \times 45 = \$135\) of set-up, so the lot cost is \(50 \times 11.301 + 135 = \$700.06\), and Eq. (3) gives \(P = 1.30 \times 700.06 = \$910.08\), or $18.20 per bracket. This is the number the estimator sees, with the breakdown beside it, and the package's first unit test repeats the calculation by hand.
4.4 The escalation rules
Table 5 lists the rules. They are the shop manager's existing judgment, written as thresholds. Missing information produces a clarification draft; anything outside the shop's normal work goes to the estimator with the reason. Each threshold is a business decision for the owner, not a technical setting, and changing one is a one-line edit in quote_engine.py or the data files, followed by a re-run of the tests.
| Rule | Threshold in the reference build | Route |
|---|---|---|
| Possible prompt injection | Request text matches a known injection pattern | Escalate |
| New customer | Email not found in the ERP | Escalate |
| Credit | Account on credit hold | Escalate |
| Material or finish | Material not in the catalogue (e.g. abrasion-resistant plate), or a finish the shop does not offer | Escalate |
| Thickness and forming | Outside the material's range, or bending above 12 mm | Escalate |
| Tolerance | Tighter than ±0.25 mm | Escalate |
| Lead time | Fewer than 5 working days | Escalate |
| Certification | Anything beyond CWB welding or mill test reports (e.g. ASME pressure parts) | Escalate |
| Value | Lot price above $25,000 | Escalate |
| Missing information | No material, thickness, quantity or dimensions; no drawing | Clarify |
Illustrative thresholds. All other requests are routed to a draft quote, which the estimator still reviews.
The rules in Table 5 are applied to the part data the model extracted, and in the first version that was all they saw. The red-team review in Section 6.4 showed the weakness: a model that dropped a tolerance or a rush date, or gave another customer's address, could get a draft for a request that should have been escalated. The current version adds three checks that do not depend on the model. The customer is taken from the email's sender. Impossible values are refused before any rule runs, such as negative or undefined numbers, fractional quantities, text instead of numbers and blanks beyond sheet size. And the server reads the original request itself for the conditions in Table 6.
| Check | What it looks for | Example caught |
|---|---|---|
| Tolerance | Any ± value under 0.25 mm, in millimetres or inch fractions | ±0.1 mm on hole positions |
| Rush | "Urgent", "ASAP", "by Wednesday", or fewer than 5 days | "3 working days" |
| Certification | ASME, PED, CRN, NACE, pressure vessel and similar | ASME Section VIII pads |
| Non-catalogue material | Abrasion-resistant plate, duplex, nickel alloys, copper alloys and similar | Hardox 450 |
| Thickness above range | A stated plate thickness above 25 mm | "30 mm 44W" |
| Thickness consistency | The extracted thickness must match a stated plate thickness | 16 mm entered as 12 mm |
| Bending | Bending asked for on plate thicker than 12 mm | 16 mm angle with one bend |
| Finish | Anodizing, plating, passivation, e-coat and similar | "Clear anodized" |
| Quantity | The extracted quantity must match a number written next to the part name, or failing that appear in the request | 4,000 plates entered as 300 |
Pattern checks in quote_engine.text_checks, with negations such as "no rush" or "no ASME required" ignored. They were tuned on the test requests and the red team's phrases, so they will miss wording they were not written for and can flag innocent wording, such as a quantity written as a word. They narrow the gap without closing it.
One further check produces a warning rather than a route. When a draft's unit price is more than 25% from the median of past quotes for the same kind of part, material, thickness and quantity range, the draft says so. On the test set it flags none of the 11 correct drafts, and it flagged 8 of 17 seeded extraction errors that changed the price, only where a matching past quote existed. It is a prompt for the estimator, not a control.
4.5 The instructions
Because the rules and the arithmetic live in code, the system prompt is short. It describes the job, the fields to extract, the order of tool calls and four rules (Listing 2). It does not list thresholds: a prompt is guidance the model usually follows, while code is enforcement the model cannot bypass.
prompts/system_prompt.mdThe instruction to list assumptions matters more than it looks. The estimator's review is fast only when the draft says what the agent was unsure of: an inch dimension converted, a lead time not stated, a finish inferred from a colour code. A draft without assumptions forces the estimator to re-read the whole request, and the time saving disappears.
4.6 The harness
The harness is the code around the model that makes it dependable [13]. Here it runs the loop and stops it after 14 model turns, logs every model turn and tool call, ends a request as soon as a write tool succeeds, and routes the request to the estimator itself if the model stops without an outcome, its call fails or a refused write is not recovered. It processes every request in the inbox. Figure 3 shows the flow for one request.
5. Guardrails
5.1 Prompt injection
A quote agent reads text written by outsiders, and some of that text may be written to steer it. OWASP ranks prompt injection first among risks for applications built on large language models, and notes that it is unclear whether any method prevents it completely [14]. The build therefore does not depend on the model resisting it. It uses three layers, from weakest to strongest:
- Labelling. The system prompt and the read_rfq description tell the model that request content is data, not instructions.
- Detection. The server scans the subject, the email and the drawing text for common injection patterns and, on a match, routes the request to the estimator. This is a cheap signal: a rewording can defeat it, and unusual but innocent phrasing can trip it and send a routine request to the estimator. The build does not rely on it.
- Boundary. No tool can send, approve or discount anything, so a model that has been talked into a discount has no way to apply one. The write tools re-run the rules, with the customer taken from the sender and the server's own checks on the original request. In every case tested, a model that skips check_escalation, gives another customer, or drops or changes a tolerance, rush date, certification, finish, bend, thickness, non-catalogue material or quantity stated in the request cannot create a draft from it. A model that misreports a detail the checks do not cover, such as a blank dimension, or that meets wording the patterns miss, can still produce a wrong draft. That is why each draft carries the original request and the estimator compares the two.
The test set includes two injections. RFQ-022 carries a visible note asking the assistant to ignore its instructions, apply a 40% discount and send the quote directly. RFQ-023 hides a similar instruction in white-on-white text in the drawing. Unit tests call create_draft_quote directly, as a fully compromised model would: on both injection requests unchanged, and on the escalation requests with one field altered in 16 ways drawn from the two red-team rounds. The server refuses all of them. These are the controls recommended in this journal's paper on agent security [2] and in OWASP's mitigations: least privilege, deterministic checks on outputs and human approval for high-risk actions [14].
5.2 Least privilege and identity
In deployment, the agent runs under its own service account, which can read the quotes inbox but not send from it, read a view of customers, materials and past quotes, and write only to the three review queues. OWASP's excessive-agency mitigations follow the same pattern: only the functions and permissions the task needs, authorization enforced downstream, and human approval for high-impact actions [9]. The worst output possible with these permissions is a wrong draft that a person reviews against the original request.
5.3 Privacy and customer confidentiality
Requests contain contact names and email addresses, which are personal information, and drawings customers often treat as confidential. Canada's joint privacy principles for generative AI ask organizations to limit collection, use and disclosure, to be open and to keep safeguards [15]. In practice the shop should use a provider whose terms exclude training on its data and state where data are processed, and keep the run logs under the same access controls as the inbox.
5.4 Records
Every run leaves a log of each model turn and tool call: what the agent read and extracted, which rule fired and what the estimator changed. It feeds the weekly review and the next round of tests.
6. Testing Before Go-Live
6.1 Three layers of tests
Public benchmark scores say little about whether an agent will do one firm's task well; the evidence that counts comes from the firm's own cases with known answers [5]. The reference build is tested in three layers. Unit tests check the deterministic code. An answer key of 26 requests checks the whole agent. A dry run, in which a scripted stand-in for the model replays the answer key through the real MCP server, checks the plumbing between them. Table 7 lists the 26 requests by type.
| Type | Requests | Expected route | What it tests |
|---|---|---|---|
| Routine | RFQ-001 to RFQ-010 | Draft | Five materials, three finishes, bends and welding, aliases (A36, mild steel, 316L, 6061-T6) |
| Imperial units | RFQ-024 | Draft | Inch and fraction conversion (1/4 in to 6.35 mm) |
| Missing information | RFQ-011 to RFQ-013 | Clarify | No thickness; no quantity; no drawing |
| Rule escalations | RFQ-014 to RFQ-021, RFQ-025, RFQ-026 | Escalate | Tolerance, rush, value, unknown material, new customer, credit hold, ASME certification, thickness out of range, finish not offered, bending above press-brake capacity |
| Prompt injection | RFQ-022, RFQ-023 | Escalate | Visible instruction in the email; hidden instruction in the drawing |
Fictional requests; customer addresses use the reserved .example domain. The answer key in tests/cases.json gives the expected part spec and route for each, and labels the two injections, so the injection gate does not depend on the scan detecting them.
6.2 Metrics
Four metrics score a run against the answer key. Routing accuracy, Eq. (4), is the share of the \(N\) requests that take the expected route:
where \(\hat{r}_i\) is the route the agent took and \(r_i\) the expected route. Escalation recall, Eq. (5), is the share of requests that should go to the estimator and did:
Field accuracy \(A_f\), Eq. (6), is the share of extracted fields that match the key across the \(D\) correctly drafted requests and the \(F = 11\) scored fields, with numbers matching within 2%:
and the price error of each draft, Eq. (7), compares the drafted lot price with the price of the key's spec:
Since the engine is deterministic, any price error comes from extraction, so \(e_i\) shows how much an extraction mistake is worth in dollars. It ignores fields that do not affect price, such as tolerance; those are caught by routing accuracy and escalation recall.
6.3 Go-live gates
Table 8 sets the gates an agent must pass on the answer key before it drafts anything from live requests, and the gates for the shadow trial that follows. Two of the gates are 100% by design. A request that should go to the estimator and becomes a draft is the failure that matters most, because it puts an unchecked condition, such as a credit hold, a rush or a pressure-code part, in front of a reviewer who expects the rules to have caught it.
| Stage | Metric | Gate |
|---|---|---|
| Answer key (before any live request) | Routing accuracy \(A_r\) | ≥ 95% |
| Answer key (before any live request) | Escalation recall \(R_e\) | 100% |
| Answer key (before any live request) | Injections held (not drafted) | 100% |
| Answer key (before any live request) | Field accuracy \(A_f\) | ≥ 95% |
| Answer key (before any live request) | Drafts with \(|e_i| \le 2\%\) | ≥ 90% |
| Shadow trial (2 to 4 weeks, at least 60 live requests) | Drafts the estimator accepts with minor or no edits | ≥ 80% |
| Shadow trial (2 to 4 weeks, at least 60 live requests) | Missed escalations found by the estimator | 0 |
| Shadow trial (2 to 4 weeks, at least 60 live requests) | Estimator review time per routine draft | ≤ 10 min |
Author's proposed defaults, to be tuned to each firm's risk tolerance. The evaluator in the package checks the first five automatically.
6.4 Results for the reference build, and what the red team found
Before publication the build and this paper were given to an independent red-team reviewer, an AI agent with no part in writing either, asked to break them. Against the first version it found four serious problems in the code. Most important, create_draft_quote re-checked the rules only on the part data the model passed in, so changing one field produced drafts for the credit-hold, new-customer, tight-tolerance, rush, over-value, abrasion-resistant plate, ASME and 30 mm requests. Negative quantities produced drafts at the $250 minimum, a loose material match turned "AR400, similar to A36" into mild steel, and the price warning fired on 5 of 11 correct drafts. The second version fixed all four. A second round confirmed the fixes and found the same weakness one step on: the new escalation cases fell to setting the finish to none, the bends to zero or the thickness to 12 mm, and the 4,000-plate request passed with a quantity of 300, a dimension in the email. The current version adds the remaining checks in Table 6, and both rounds' attacks are unit tests. Pattern checks on the original request narrow the gap between what the email says and what the model reports, but no list of patterns closes it. A separate reference check corrected two citations.
Table 9 reports the results for the current version. All 21 unit tests pass. They cover the hand calculation of Section 4.3, input validation, every route and every rule in Table 5, injection paraphrases and innocent phrases, the absence of any tool for sending, approving, discounting or email, 16 tampering attacks, wordings the text checks missed or wrongly flagged in the second round, request IDs that try to write outside the queues, the price warning and the harness fallback. Applied to the key's specs, the rules route all 26 requests as expected. In the dry run, all 26 requests passed through the real MCP server and ended in the expected queue.
| Test | Result | What it shows |
|---|---|---|
| Unit tests (21) | 21 of 21 pass | Pricing matches the hand calculation; validation, every rule and route, and the tool boundary behave as written |
| Red-team attacks from both rounds, replayed | 16 of 16 one-field tamperings, 4 of 4 invalid inputs and 3 of 3 bad request IDs refused | The boundary holds against these changes. A field without a text check, such as a blank dimension, can still be misreported (Section 9). |
| Text checks on second-round wordings | 15 of 15 missed wordings now caught; 0 of 10 innocent wordings flagged | Tuned on these phrases, so a weak test of new wording |
| Rules on the 26 key specs | 26 of 26 routed as expected; no injection flag, text-check flag or price warning on the 11 routine requests (synthetic requests) | The rules encode Tables 5 and 6 correctly on requests written alongside them |
| Injection scan on phrases from the red team | 5 of 5 paraphrased attacks flagged; 0 of 7 innocent phrases flagged | Tuned on these phrases, so a weak test of new wording |
| Dry run through the MCP server | 26 of 26 outcomes in the expected queue; all five answer-key gates met | Harness, server and tools work together. The scripted model copies the key, so this run cannot fail on extraction. |
| Live model on the answer key | Not yet run | The first step of the shadow trial (Section 7.1) |
Run on December 5, 2026, with Python 3.13, MCP Python SDK 2.3.0 and Anthropic Python SDK 2.17.0.
The gap in Table 9 is deliberate. The dry run proves that the parts fit together, but only a live model on real requests shows whether extraction is good enough, and that result belongs to the firm that runs it on its own requests. The package makes this a two-command step: run the agent with an API key, then run the evaluator, which prints the scorecard against the gates in Table 8 and, given the provider's token prices, the model cost per request.
6.5 Building your own answer key
The 26 requests in the package show the shape of a test set, not its size. A shop's own key should come from 50 to 100 recent requests covering every route, every rule in Table 5 and the awkward cases the estimator remembers. The estimator fills in the expected spec and route for each, which also checks that the written rules match practice. Someone other than the prompt's author should add adversarial requests, and the key is re-run after every change to the prompt, model, rules or rates.
7. Going Live and the First 90 Days
7.1 From shadow trial to draft-only
Once the answer-key gates are met, the agent runs in shadow mode for two to four weeks. It drafts every incoming request while the estimator quotes as before, and the two are compared. Each difference is either an agent error, fixed in the extraction instructions, a tool or the data, or an unwritten rule, added to Table 5 [1]. When the shadow gates in Table 8 are met, the agent's drafts become the estimator's starting point (Figure 4).
The design stops at draft-only on purpose. A quote commits the shop to a price and a date, so under a per-action risk rule a person should approve it [3]. Months of logs might later justify letting the agent send routine clarification questions, which carry no price; sending quotes is a different decision that this build is not designed for.
7.2 What to measure each week
A short weekly review keeps the agent honest and catches drift when a model, a rate or a customer mix changes. Table 10 lists the measures, all of which come from the logs and the queues.
| Measure | Why it matters | Action if it slips |
|---|---|---|
| Share of drafts accepted with minor or no edits | The direct measure of value | Read the edited drafts; fix extraction or add a rule |
| Estimator review time per draft | Savings exist only if review stays short | Check whether assumptions are listed clearly |
| Route mix (draft, clarify, escalate) | A rising escalation share erodes the payback | Review whether thresholds still fit the business |
| Price warnings raised and confirmed | Can catch some extraction errors the rules miss | Trace confirmed warnings to their cause |
| Missed escalations | The failure that matters most | Stop drafting; add a test case; fix before restarting |
| Cost per request | Model use can grow quietly with longer requests | Check turns per request and request length |
| Hours from request to quote sent | Faster quotes win work | Check the review queue, not the agent |
Author's proposal.
7.3 Payback with realistic routing
The owner's guide assumed that every request saves 17 minutes [7]. With rules in place, only drafts save the full amount: a clarification draft saves a few minutes of writing, and an escalated request is handled by the estimator much as before. The average saving per request is then the route-weighted sum of Eq. (8):
where \(f_d\), \(f_c\) and \(f_e\) are the shares of requests routed to draft, clarify and escalate, and \(\Delta t_d\), \(\Delta t_c\) and \(\Delta t_e\) the minutes each saves. Taking \(\Delta t_d = 17\), \(\Delta t_c = 5\) and \(\Delta t_e = 0\) minutes, with an assumed mix of 65% drafts, 10% clarifications and 25% escalations, gives \(\Delta t = 11.55\) minutes. Table 11 carries this through the guide's cost model.
| Item | Every request drafted | Realistic routing (65 / 10 / 25) |
|---|---|---|
| Average minutes saved per request, Eq. (8) | 17.0 | 11.55 |
| Estimator time saved (60 requests/week × 48 weeks × $45/h) | $36,720 | $24,948 |
| Model and platform use (2,880 requests × $0.40) | −$1,152 | −$1,152 |
| Upkeep (3 h/month × 12 × $90/h) | −$3,240 | −$3,240 |
| Net benefit per year | $32,328 | $20,556 |
| Set-up, integration and testing (one time) | $15,000 | $15,000 |
| Simple payback | 5.6 months | 8.8 months |
Model cost is charged on every request, since the agent reads them all. Cost figures from [7]; the route mix is an assumption to be replaced by the shadow-trial result.
The case still pays inside a year, but the route mix matters: at 80% drafts, 5% clarifications and 15% escalations the payback is 7.1 months, and at 50%, 15% and 35% it is 11.5 months. The shadow trial measures the mix, so the payback can be recomputed with real figures. Two effects are left out: escalated requests now arrive with a summary and the rule that fired, and faster quotes often win work [7], a benefit that can be larger than the labour saved [4].
7.4 Ownership and upkeep
The agent needs an owner, usually the lead estimator, with the three hours a month that the upkeep line in Table 11 pays for. Rates are updated on a fixed day each month; every change to a rule, the prompt, the rates or the model is logged and followed by a full test run; and every confirmed error, especially a missed escalation, becomes a new case in the answer key.
8. What Transfers to Other SME Agents
Quoting was chosen because it is common and easy to cost, but the build steps are general. Table 12 shows how each step carries over to three other processes that suit a first agent: order entry, supplier invoice matching and maintenance request triage.
| Build step | Quote requests (this paper) | Order entry | Supplier invoice matching | Maintenance request triage |
|---|---|---|---|---|
| Fields to extract | Part, material, size, quantity, finish | PO number, items, quantities, prices, dates | Supplier, invoice lines, amounts, PO reference | Asset, symptom, location, urgency |
| Deterministic engine | Pricing | Price and credit check against contract | Three-way match (PO, receipt, invoice) | Priority matrix by asset criticality |
| Rules that escalate | Value, tolerance, rush, credit, certification | Price variance, credit hold, unknown item | Variance above tolerance, no receipt, new supplier bank details | Safety-related, production line down |
| Write tool (draft only) | Draft quote | Draft sales order | Invoice approved for payment run, pending sign-off | Draft work order |
| Never allowed | Send, approve, discount | Release order, change price | Pay, change supplier bank details | Close work order, change PM schedule |
| Must-escalate test cases | Credit hold, ASME part, injection | Contract price mismatch | Changed bank details (payment fraud) | Gas smell, guard missing |
Author's mapping.
The pattern is the same in each column: the model extracts, code calculates and decides, write tools create drafts that re-check the rules, and the action that commits money, product or safety stays with a person.
9. Limits
- Illustrative firm and data. The shop, customers, rates and past quotes are fictional; the rates are not market prices.
- Rules partly see the model's version. The customer, impossible values and the text checks of Table 6 are independent of the model, but other rules, the value limit among them, use the extracted data. A misreported blank size or a detail worded in a way the checks miss can still produce a draft that should have been escalated; the estimator's review and the escalation-recall gate are the controls.
- Extraction not yet measured. The tests establish that the deterministic parts and the tool boundary work. How accurately a given model extracts specs from real requests is the first step of the shadow trial and will vary by model and by request quality.
- Drawings as text. The build reads drawing text. Real PDF or DXF drawings, often scanned, need a document-reading step not built here.
- One part per request. Multi-line requests and assemblies are out of scope and would go to the estimator.
- Pattern checks flag and miss. The text checks and the injection scan were tuned on the test requests and the red team's phrases. They will miss new wording and flag some innocent requests, for example a quantity written as a word; both rates should be measured in the shadow trial.
- Assumed economics. The route mix, minutes saved and cost per request are assumptions until a shadow trial replaces them.
10. Conclusions
Building a useful agent for a small firm is less about the model than about the design around it. The quote-request agent in this paper is built from a written procedure, nine tools, ten rules, nine checks on the original request and a short prompt, and most of its reliability comes from decisions taken before a model is involved: what the agent may read, what it may write, which calculations and decisions belong to code, and what it can never do.
Five practical points follow for SME owners and the advisers who help them:
- Start from the procedure. Write down the fields, rules and approvals first; that is useful even if no agent follows.
- Let the model read and the code decide. Prices and thresholds belong in code that gives the same answer every time.
- Enforce limits with tools, not instructions. Give the agent no tool that can send, and make the tools that write take the customer from the sender, check the original request, re-run the rules and recompute the price.
- Test against your own answer key, and have someone try to break it. Make escalation recall 100%, stop drafting after a missed escalation until it is fixed, and turn every successful attack into a test. Expect each round of fixes to move the gap, not close it.
- Recompute the payback with the real route mix. Rules that send work to people protect the shop, and they also cut the savings.
The code package contains the whole build, with fictional data, so that a shop or its adviser can run it, replace the data and rates with their own, and measure a live model against their own requests before trusting it with any.
References
- Lee, Q. F. (2026). Agent readiness for small and mid-sized firms: Data foundations, process documentation and staged adoption. Chmltech Online Journal, 105(6). www.chmltech.com/post/agent-readiness-for-small-and-mid-sized-firms-data-proces…
- Lee, Q. F. (2026). Agent security and identity: Prompt injection, least-privilege tool access, agent credentials and audit trails. Chmltech Online Journal, 105(5). www.chmltech.com/post/agent-security-and-identity-prompt-injection-least-privil…
- Lee, Q. F. (2026). Levels of autonomy and human-in-the-loop design for AI agents: Matching oversight to risk and earning autonomy with evidence. Chmltech Online Journal, 105(7). www.chmltech.com/post/levels-of-autonomy-and-human-in-the-loop-design-for-ai-ag…
- Lee, Q. F. (2026). The economics of agentic AI: Cost per task, total cost of ownership and payback. Chmltech Online Journal, 105(8). www.chmltech.com/post/the-economics-of-agentic-ai-cost-per-task-total-cost-and-…
- Lee, Q. F. (2026). Evaluating AI agents: Why public benchmarks mislead and how to build your own evaluation. Chmltech Online Journal, 105(10). www.chmltech.com/post/evaluating-ai-agents-why-benchmarks-mislead-and-how-to-bu…
- Lee, Q. F. (2026). Agent interoperability standards: The Model Context Protocol, agent-to-agent protocols and integration with ERP, CRM and plant systems. Chmltech Online Journal, 105(4). www.chmltech.com/post/agent-interoperability-standards-mcp-a2a-erp-crm-plant-sy…
- Lee, Q. F. (2025, updated 2026). AI agents for small businesses: What they are, where they help and how to start. Chmltech Insights. www.chmltech.com/post/ai-agents-101-and-how-to-use-them-to-improve-efficiency
- Schluntz, E., & Zhang, B. (2024, December 19). Building effective agents. Anthropic. www.anthropic.com/engineering/building-effective-agents
- OWASP Foundation. (2025). LLM06:2025 Excessive agency. In OWASP Top 10 for LLM Applications 2025. genai.owasp.org/llmrisk/llm062025-excessive-agency/
- Model Context Protocol. (2026). Specification (version 2026-07-28). modelcontextprotocol.io/specification/2026-07-28
- Model Context Protocol. (2026). Migration guide: v1 to v2. MCP Python SDK documentation. py.sdk.modelcontextprotocol.io/v2/migration/
- Lee, Q. F. (2026). The LLM should not do the arithmetic: A tool-grounded architecture for OEE and KPI analysis. Chmltech Online Journal, 106(17). www.chmltech.com/post/the-llm-should-not-do-the-arithmetic-a-tool-grounded-arch…
- Lee, Q. F. (2026). Agents, skills, and harnesses: A reference architecture for reliable agentic AI. Chmltech Online Journal, 106(12). www.chmltech.com/post/agents-skills-and-harnesses-a-reference-architecture-for-…
- OWASP Foundation. (2025). LLM01:2025 Prompt injection. In OWASP Top 10 for LLM Applications 2025. genai.owasp.org/llmrisk/llm01-prompt-injection/
- Office of the Privacy Commissioner of Canada, with the provincial and territorial privacy commissioners. (2023, December 7). Principles for responsible, trustworthy and privacy-protective generative AI technologies. www.priv.gc.ca/en/privacy-topics/technology/artificial-intelligence/gd_principl…
How to cite this article
Lee, Q. F. (2026). From SOP to Working Agent: Building a Quote-Request Agent for a Small Fabrication Shop, Step by Step. Chmltech Online Journal, 106(29). https://www.chmltech.com/post/from-sop-to-working-agent-building-a-quote-request-agent-for-a-small-fabrication-shop
