Home / Insights / Chmltech Online Journal

Chmltech Online JournalVolume 106, Issue 29Research article

From SOP to Working Agent: Building a Quote-Request Agent for a Small Fabrication Shop, Step by Step

Quak Foo LeeChief Technology Officer, Chmltech Ltd.Division of Artificial Intelligence and Machine Learning · Vancouver, BC, Canada

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).

Swim lane diagram of the quote process before the agent. The customer emails a request with a drawing. The estimator reads it, looks up material, past jobs and rates in the ERP and spreadsheets, prices it in a spreadsheet and checks whether it needs the shop manager. Large or unusual quotes go to the shop manager for approval. The estimator then writes and sends the quote. About 25 minutes of estimator time per request, plus waiting time in the estimator's queue.CustomerEstimatorERP andfilesShopmanagerEmail requestwith drawingRead requestand drawingLook up customer,material, past jobsERP, pricespreadsheetsPrice inspreadsheetLarge orunusual?Review andapproveWrite andsend quoteReceive quoteyesno≈ 25 min perrequest (illustrative)
Figure 1. The quoting process before the agent. The estimator does every step, from reading the request to sending the quote, and the shop manager approves large or unusual quotes. Times are illustrative.

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.

Table 1. Estimator time per request before and after the agent (illustrative).
StepBefore (min)Who does it with the agentAfter (min)
Read request and drawing, list what is asked6Agent extracts a structured part spec0
Look up customer, material and similar past jobs6Agent, through read-only tools0
Price the part7Pricing engine (deterministic code)0
Check large or unusual jobs with the shop manager2 (average)Rules route these to the estimator0 for drafts
Review the draft, correct it and send it4 (write and send)Estimator8
Total per routine request258

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.

Table 2. The quoting procedure mapped to the agent specification.
SOP elementAgent specificationIn the reference build
Purpose and scopeGoal and boundariesDraft quotes for single cut, formed, welded or finished parts; not assemblies or design advice
TriggerEvent that starts a runA new message in the quotes inbox
InputsFields to extract15 fields: customer, part, material, thickness, blank length, blank width, cut length, bends, weld minutes, finish, quantity, tolerance, lead time, certification, drawing present
Records consultedRead toolsRequest, customer account, material catalogue, past quotes, price calculation, rule check
OutputWrite toolsDraft quote, clarification draft or hand-off to the estimator, each saved for review
Decision rulesRules in codeTen written rules (Table 5) that return draft, clarify or escalate
ApprovalsHuman-in-the-loop pointsThe estimator approves and sends every quote; the agent cannot send
Records keptAudit trailEvery model turn and tool call logged per request
Performance measuresMetrics and gatesRouting 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.

Architecture of the reference build. Requests arrive in an inbox. An agent runner, the harness, runs the loop with a turn limit, logging and a fallback that routes unfinished requests to the estimator. It sends messages to a tool-using language model and executes the model's tool calls on an MCP server. The server has six read tools and three write tools; the write tools only create drafts or queue items and recompute price and rules. Behind the server, a deterministic engine does pricing, rules and look-ups over the shop's data: customers, materials, rates and past quotes. Outputs go to three queues that the estimator works from. Logs feed an audit trail.Inboxemail + drawingAgent runner (harness)loop · 14-turn limitlog · fallbackLanguage model(any tool-using model)MCP server6 read tools (incl. inbox)3 write tools (drafts only)Deterministic enginepricing · rules · look-upsShop datacustomers · materialsrates · past quotesDraft quotesQuestionsEscalationsEstimatorreviews andsendsRun logsevery turn andtool callrequest IDsmessagestool callscallresultlogsBoundary: no tool can send email, approve,discount or change a record. Write toolstake the customer from the sender, checkthe original request, re-run the rulesand recompute the price.
Figure 2. Architecture of the reference build. The model never touches the shop's data or the queues directly: it can only ask the harness to call a tool, and the tools enforce the boundary.

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:

  1. Read tools never change anything. They return data. In deployment, the ERP account behind them is read-only.
  2. 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.
  3. 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.
Table 3. The agent's tools.
ToolTypeWhat it doesGuard
read_rfqReadReturns the email and the drawing text, labelled as untrusted customer contentRead-only inbox access; valid request IDs only
get_customerReadLooks up the account, terms and credit status in the ERPRead-only ERP view
get_materialReadMaps a grade exactly as written (A36, 316L, 5052) to a catalogue code and thickness rangeExact matches only, so "AR400, similar to A36" is not found
find_similar_quotesReadReturns up to three similar past quotes with unit price and whether they were wonRead-only
price_partReadPrices one line by Eqs. (1) to (3) and returns the breakdownDeterministic; impossible values refused
check_escalationReadApplies the ten rules of Table 5 and the server's checks on the original request; returns draft, clarify or escalateCustomer taken from the sender
create_draft_quoteWriteSaves a draft quote with price breakdown, similar quotes, any price warning, the agent's assumptions and the original requestRe-runs all checks and the price; refuses unless the route is draft
request_clarificationWriteSaves the questions for the estimator to sendRefuses unless the route is clarify; does not send
route_to_estimatorWriteHands the request over with the agent's reasons and the rules' reasonsAlways 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.

Listing 1. Two of the nine tools in server.py (abridged).
server.py

4.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):

\[m = \rho \, L \, W \, t, \qquad C_{\mathrm{mat}} = m \, p_{\mathrm{kg}} \, (1 + s)\](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):

\[c_u = C_{\mathrm{mat}} + \ell_{\mathrm{cut}} \, c_{\mathrm{cut}}(t) + n_b \, c_b + \frac{t_w}{60} \, r_w + C_{\mathrm{fin}}\](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:

\[P = \max\!\left[(1 + k)\left(q \, c_u + n_{\mathrm{op}} \, c_{\mathrm{set}} + C_{\mathrm{lot}}\right),\; P_{\min}\right]\](3)

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.

Table 4. Illustrative shop rates used by the pricing engine (CAD, before taxes).
RateValueRateValue
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 operationPowder coat$28/m²
Minimum order \(P_{\min}\)$250Galvanizing$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 mmCutting factor×1.4 stainless; ×1.2 aluminum
44W carbon steel$1.65/kg304 / 316 stainless$6.20 / $7.90 per kg
5052 / 6061 aluminum$7.40 / $7.10 per kgDensities \(\rho\)7850 carbon; 7930 / 7980 stainless; 2680 / 2700 aluminum (kg/m³)
Press brakeBending up to 12 mmSheet and plate sizeBlanks 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.

Table 5. Routing rules applied by check_escalation.
RuleThreshold in the reference buildRoute
Possible prompt injectionRequest text matches a known injection patternEscalate
New customerEmail not found in the ERPEscalate
CreditAccount on credit holdEscalate
Material or finishMaterial not in the catalogue (e.g. abrasion-resistant plate), or a finish the shop does not offerEscalate
Thickness and formingOutside the material's range, or bending above 12 mmEscalate
ToleranceTighter than ±0.25 mmEscalate
Lead timeFewer than 5 working daysEscalate
CertificationAnything beyond CWB welding or mill test reports (e.g. ASME pressure parts)Escalate
ValueLot price above $25,000Escalate
Missing informationNo material, thickness, quantity or dimensions; no drawingClarify

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.

Table 6. Checks the server runs on the original request text, whatever the model extracted.
CheckWhat it looks forExample caught
ToleranceAny ± 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"
CertificationASME, PED, CRN, NACE, pressure vessel and similarASME Section VIII pads
Non-catalogue materialAbrasion-resistant plate, duplex, nickel alloys, copper alloys and similarHardox 450
Thickness above rangeA stated plate thickness above 25 mm"30 mm 44W"
Thickness consistencyThe extracted thickness must match a stated plate thickness16 mm entered as 12 mm
BendingBending asked for on plate thicker than 12 mm16 mm angle with one bend
FinishAnodizing, plating, passivation, e-coat and similar"Clear anodized"
QuantityThe extracted quantity must match a number written next to the part name, or failing that appear in the request4,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.

Listing 2. Excerpt of the system prompt in prompts/system_prompt.md.
prompts/system_prompt.md

The 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.

Flow for one request. The agent reads the request, extracts the part spec, and checks the customer and material. The check_escalation tool applies the shop's rules and returns one of three routes. Draft: the pricing tool computes the price and the agent saves a draft quote; the write tool re-checks the customer, the original request and the rules, and refuses if they do not allow a draft, in which case the request goes to the estimator. Clarify: the agent saves the questions the rules returned. Escalate: the agent routes the request to the estimator with the reasons. All three outcomes go to the estimator. If the agent does not finish within 14 turns, or the model call fails, the harness routes the request to the estimator.read_rfqExtractpart specget_customerget_materialcheck_escalationRoute?price_part,similar quotescreate_draft_quoterequest_clarificationroute_to_estimatorclarifydraftescalaterefusedRe-checks customer,request and rules;refuses if not a draftHarness fallback: no outcome within 14 turns,or the model call fails → route_to_estimatorEvery outcome goes to the estimator
Figure 3. The flow for one request. The rules decide the route, and every route ends with the estimator. A refused draft goes to the estimator, and the harness guarantees an outcome even if the model stalls or its call fails.

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:

  1. Labelling. The system prompt and the read_rfq description tell the model that request content is data, not instructions.
  2. 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.
  3. 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.

Table 7. The 26 test requests in the answer key.
TypeRequestsExpected routeWhat it tests
RoutineRFQ-001 to RFQ-010DraftFive materials, three finishes, bends and welding, aliases (A36, mild steel, 316L, 6061-T6)
Imperial unitsRFQ-024DraftInch and fraction conversion (1/4 in to 6.35 mm)
Missing informationRFQ-011 to RFQ-013ClarifyNo thickness; no quantity; no drawing
Rule escalationsRFQ-014 to RFQ-021, RFQ-025, RFQ-026EscalateTolerance, rush, value, unknown material, new customer, credit hold, ASME certification, thickness out of range, finish not offered, bending above press-brake capacity
Prompt injectionRFQ-022, RFQ-023EscalateVisible 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:

\[A_r = \frac{1}{N} \sum_{i=1}^{N} \mathbf{1}\!\left[\hat{r}_i = r_i\right]\](4)

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:

\[R_e = \frac{\left|\{\,i : \hat{r}_i = r_i = \text{escalate}\,\}\right|}{\left|\{\,i : r_i = \text{escalate}\,\}\right|}\](5)

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%:

\[A_f = \frac{1}{D\,F} \sum_{i=1}^{D} \sum_{j=1}^{F} \mathbf{1}\!\left[\hat{x}_{ij} \approx x_{ij}\right]\](6)

and the price error of each draft, Eq. (7), compares the drafted lot price with the price of the key's spec:

\[e_i = \frac{\hat{P}_i - P_i}{P_i}\](7)

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.

Table 8. Go-live gates.
StageMetricGate
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 estimator0
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.

Table 9. Test results for the reference build.
TestResultWhat it shows
Unit tests (21)21 of 21 passPricing matches the hand calculation; validation, every rule and route, and the tool boundary behave as written
Red-team attacks from both rounds, replayed16 of 16 one-field tamperings, 4 of 4 invalid inputs and 3 of 3 bad request IDs refusedThe 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 wordings15 of 15 missed wordings now caught; 0 of 10 innocent wordings flaggedTuned on these phrases, so a weak test of new wording
Rules on the 26 key specs26 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 team5 of 5 paraphrased attacks flagged; 0 of 7 innocent phrases flaggedTuned on these phrases, so a weak test of new wording
Dry run through the MCP server26 of 26 outcomes in the expected queue; all five answer-key gates metHarness, server and tools work together. The scripted model copies the key, so this run cannot fail on extraction.
Live model on the answer keyNot yet runThe 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).

Swim lane diagram of the quote process with the agent. The customer emails a request. The agent reads it and extracts a part spec, checks the customer and material through the tools, and applies the shop's rules through a tool that returns draft, clarify or escalate. For a draft, the pricing engine computes the price and the agent saves a draft quote; otherwise it saves questions or routes the request with reasons. Every outcome lands in the estimator's review queue. The estimator reviews, edits, approves and sends the quote. The agent has no tool that can send.CustomerAgentTools andsystems (MCP)EstimatorEmail requestwith drawingRead andextract specCheck customerand materialERP look-ups(read only)Apply shoprulesRules andpricing engineSave draft, questionsor escalationReview queueReview, edit,approve and sendReceive quoteor questionsEstimator time ≈ 8 minper routine draft (illustrative)No tool can send,approve or discount
Figure 4. The quoting process with the agent. The agent reads, looks up and routes; the rules and the pricing engine decide; the estimator reviews, edits, approves and sends a quote, or sends the questions. Times are illustrative; 8 minutes applies to a routine draft.

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.

Table 10. Weekly measures after go-live.
MeasureWhy it mattersAction if it slips
Share of drafts accepted with minor or no editsThe direct measure of valueRead the edited drafts; fix extraction or add a rule
Estimator review time per draftSavings exist only if review stays shortCheck whether assumptions are listed clearly
Route mix (draft, clarify, escalate)A rising escalation share erodes the paybackReview whether thresholds still fit the business
Price warnings raised and confirmedCan catch some extraction errors the rules missTrace confirmed warnings to their cause
Missed escalationsThe failure that matters mostStop drafting; add a test case; fix before restarting
Cost per requestModel use can grow quietly with longer requestsCheck turns per request and request length
Hours from request to quote sentFaster quotes win workCheck 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):

\[\Delta t = f_d \, \Delta t_d + f_c \, \Delta t_c + f_e \, \Delta t_e\](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.

Table 11. Payback with every request drafted (as in [7]) and with realistic routing (illustrative).
ItemEvery request draftedRealistic routing (65 / 10 / 25)
Average minutes saved per request, Eq. (8)17.011.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 payback5.6 months8.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.

Table 12. The build steps applied to other SME processes.
Build stepQuote requests (this paper)Order entrySupplier invoice matchingMaintenance request triage
Fields to extractPart, material, size, quantity, finishPO number, items, quantities, prices, datesSupplier, invoice lines, amounts, PO referenceAsset, symptom, location, urgency
Deterministic enginePricingPrice and credit check against contractThree-way match (PO, receipt, invoice)Priority matrix by asset criticality
Rules that escalateValue, tolerance, rush, credit, certificationPrice variance, credit hold, unknown itemVariance above tolerance, no receipt, new supplier bank detailsSafety-related, production line down
Write tool (draft only)Draft quoteDraft sales orderInvoice approved for payment run, pending sign-offDraft work order
Never allowedSend, approve, discountRelease order, change pricePay, change supplier bank detailsClose work order, change PM schedule
Must-escalate test casesCredit hold, ASME part, injectionContract price mismatchChanged 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:

  1. Start from the procedure. Write down the fields, rules and approvals first; that is useful even if no agent follows.
  2. Let the model read and the code decide. Prices and thresholds belong in code that gives the same answer every time.
  3. 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.
  4. 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.
  5. 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

  1. 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…
  2. 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…
  3. 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…
  4. 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-…
  5. 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…
  6. 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…
  7. 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
  8. Schluntz, E., & Zhang, B. (2024, December 19). Building effective agents. Anthropic. www.anthropic.com/engineering/building-effective-agents
  9. OWASP Foundation. (2025). LLM06:2025 Excessive agency. In OWASP Top 10 for LLM Applications 2025. genai.owasp.org/llmrisk/llm062025-excessive-agency/
  10. Model Context Protocol. (2026). Specification (version 2026-07-28). modelcontextprotocol.io/specification/2026-07-28
  11. Model Context Protocol. (2026). Migration guide: v1 to v2. MCP Python SDK documentation. py.sdk.modelcontextprotocol.io/v2/migration/
  12. 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…
  13. 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-…
  14. OWASP Foundation. (2025). LLM01:2025 Prompt injection. In OWASP Top 10 for LLM Applications 2025. genai.owasp.org/llmrisk/llm01-prompt-injection/
  15. 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

Chmltech Online Journal · Vol. 106, Issue 29

Download the PDF

From SOP to Working Agent: Building a Quote-Request Agent for a Small Fabrication Shop, Step by Step

We use your details to record this request and may follow up about it. See our privacy notice.