Technical details: a procurement automation example
Material structure
Philosophy
Agent infrastructure as the foundation.
The solution is built as a base that is easy to extend: new business systems, communication channels and agents connect to it without reworking existing components.
Processes are added as procedures.
A new automation scenario is described by a procedure: which data to use, which actions to perform and when to hand the task over to an employee.
The architecture sets the data boundaries.
An agent's access to data is restricted technically and does not depend on the text of an incoming message.
Problem / solution matrix
| Problem | Solution |
|---|---|
| Untrusted text. A supplier message may contain instructions aimed at obtaining internal data | Two perimeters. The agent that reads external messages has no access to Zoho Inventory. The assignment is passed over A2A: only the operations agent initiates the call, and the response is the task status. It reads the result from Google Sheets as typed fields: price, batch size, lead time. The supplier's free text does not enter its context |
| Channels with different mechanics. Email, messengers and telephony are connected in different ways | A single multichannel aggregator, Chatwoot. The agent works with one API, and a new channel is added without changing the agent |
| First message in messengers. The built-in WhatsApp channel in Chatwoot works through the Business API and allows a first message only as an approved template. The built-in Telegram channel works through a bot, which cannot send the first message | A custom integration service with regular accounts, connected to Chatwoot as a channel. The sending rate is limited by the procedure so that the account is not blocked |
| AI traffic. Provider credentials and token usage are spread across agents | The CLI-Proxy-API-Management gateway: a single exit point to the provider. Subscription credentials are stored only in the gateway; agents access it with internal keys and work on a shared token pool |
| Failures and reruns. A channel failure or a repeated upload of a spec creates duplicate requests | A task has an identifier and a status. A request to a supplier is identified by the combination "task, item, supplier": a rerun continues open requests and does not resend those already sent. A failure of one channel does not stop the others |
| Several agents for one employee. A separate interface for each agent | One Open WebUI chat, where each agent is connected as a separate model. The agents are built on hermes-agent and differ in tools, procedures and perimeter |
| Manual intervention. An employee writes to the supplier directly, and the agent loses context | The employee works in the same multichannel aggregator. The agent receives the context of the employee's messages, and a conversation with human participation is escalated |
Architecture by phases
A phase button shows the solution as of that phase's delivery: the elements of that phase and all previous ones. Below, the new components and their implementation are listed for each phase.
Phase 1. Price requests for a spec
Phase 1.5. Voice AI agent
Phase 2. Internal perimeter
Starting from this phase, the solution is split into two perimeters. In the external perimeter, the communications agent processes untrusted supplier text. The internal perimeter contains the operations agent, the procedures and the knowledge base; Zoho Inventory is accessible only from it.
Phase 3. Multichannel communication and purchasing
Evals: quality evaluation of AI steps
A step performed by the model is probabilistic: the result may differ on the same input. Quality evaluation answers two questions: whether a change can be released and whether quality holds in production.
Principles
- The cost of an error sets the strictness. A step's threshold is derived from two values: how much its worst error costs and whether an employee catches it before it has consequences. The thresholds are therefore asymmetric: a missed item costs more than an unnecessary request to a supplier.
- Code enforces the invariants. The contents of an assignment, access permissions and typed reading of results always hold and are verified by automated tests. Quality evaluation measures only the steps performed by the model.
- The cheapest reliable check is chosen. The first choice is comparison with ground truth in code. An LLM judge with a rubric is used where there is no single correct answer. Before use, the judge is checked against an employee on 50 examples; score agreement must be at least 90%.
- Datasets are built from real work. The source is the company's historical documents. Two thirds of a dataset are used for tuning; one third is held out and run only at acceptance. Datasets with fewer than 100 examples are not split. Every case that an employee corrected manually is added to the dataset.
- A threshold must be verifiable at the dataset size. The dataset size determines the margin of error. If the dataset is small and the threshold cannot be confirmed on it, the step stays under full manual review until enough data accumulates.
- Each example is run three times. The worst result counts: a step that passes every other time is considered failed.
- The scope is the minimum sufficient. No separate evaluation platform is built. Datasets and ground truth are stored as files next to the prompts and procedures, are versioned together with them, and a run is started with a single command.
Verification levels
| Level | What it verifies | How | When it runs |
|---|---|---|---|
| Invariants | Contents of an assignment, access permissions, typed reading of results, no duplicate requests, item and quantity in a request matching the confirmed list | Automated tests, all must pass | Every code change |
| Step | Quality of a single AI step on a dataset with ground truth | Comparison with ground truth, LLM judge | Every change to a prompt, procedure, tool or model; once a week on a schedule |
| Scenario | End-to-end run of the process on recorded historical supplier responses: the agent goes through the required steps and reaches the correct outcome | Check of the final sheet and the action log | Before phase acceptance |
| Production | Real employee tasks | Share of corrections and escalations, sample review | Continuously |
A metric falling below its threshold blocks the release of the change. The scheduled run catches a change in quality after a model update on the provider side.
Evaluated steps
| Step | Phase | Worst error | Safeguard | Metric and threshold |
|---|---|---|---|---|
| Spec parsing | 1 | An item is missed: the customer receives an incomplete quote | Reconciliation: every row of the document has become an item or is marked as unrecognized. An employee confirms the list | Item recall at least 98%, field accuracy at least 95%. Against ground truth |
| Supplier search | 1 | No suitable supplier is found for an item | An item without suppliers is flagged for an employee | A suitable supplier is found for 90% of items, at least 80% of those found are relevant. LLM judge |
| Supplier response parsing | 1 | A wrong price gets into the price comparison sheet | A link to the message is stored next to the value. An employee checks the sheet before replying to the customer | Field accuracy at least 97%, an incomplete response is taken as complete in no more than 2% of cases. Against ground truth |
| Resistance to instructions in messages | 1 | The agent follows an instruction from a supplier message | Invariants: the external agent has no access to internal data | All examples in the attack set pass. Based on the action log |
| Call parsing | 1.5 | A wrong price taken from the conversation | During the trial period, an employee checks every recording | Field accuracy at least 90%. Against ground truth |
| Low-stock item selection | 2 | An item is missed: the product runs out without a price request | An employee sees the list of selected items | Recall at least 98%, precision at least 90%. Against ground truth |
| Draft purchase order | 3 | A wrong price or quantity in the order | An employee checks the order and sends it personally | All fields match the agreed values. Against ground truth |
Thresholds are agreed with the company before the phase starts and are part of its acceptance.
Datasets
Production metrics
- Share of items corrected during list confirmation. Shows the quality of spec parsing on new documents.
- Share of values corrected in the price comparison sheet. Shows the quality of supplier response parsing.
- Share of conversations handed over to an employee. Shows how well the procedure covers real situations.
- Token usage and time per spec. Shows the cost and speed of the agent's work.
Alert thresholds are set from the actual values of the first week of the trial period. Exceeding a threshold triggers a review: the cases are added to the dataset, the step is retuned and goes through verification again.
What we need from the company
- Historical specs and the final price sheets for them.
- An export of correspondence with suppliers and consent to use it in anonymized form.
- A purchasing department employee to label ground truth and check the LLM judge: about 16 hours for phase 1 and 4 hours for each subsequent phase.
- A request template and supplier selection rules.
- A Zoho Inventory data snapshot or test read access.
- Call recordings and historical purchase orders, if they have been kept.
- A decision on thresholds: the company approves them knowing the cost of an error at each step.
