Technical details: a procurement automation example

Material structure
3AI agents
2data perimeters
4communication channels
8external systems

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

ProblemSolution
Untrusted text. A supplier message may contain instructions aimed at obtaining internal dataTwo 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 waysA 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 messageA 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 agentsThe 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 requestsA 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 agentOne 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 contextThe 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.

Phases
diagram…
People and interfaceAI agentsCommunication channelsInternal protected perimeterAI traffic gatewayWorking data and external sources

Phase 1. Price requests for a spec

Base infrastructure for AI agentsAgent runtime environment, permissions and action log
On company infrastructure
AI traffic gatewayAll AI traffic from agents to the provider, company subscription
CLI-Proxy-API-Management
AI agent chatThe single entry point for an employee to the agents
Open WebUI
Communications AI agentInteraction with suppliers
hermes-agent
Web searchSupplier search for each item
Agent web search tool
Multichannel aggregatorCommunication channels; API and webhooks for the agent; employee interface for viewing conversations and replying manually
Chatwoot
WhatsAppSending and receiving from a regular number, first message to a supplier
Custom integration service
Google SheetsRegister of prices and terms, read and write
Service account

Phase 1.5. Voice AI agent

TelephonyOutbound and inbound calls, dedicated number
Provider is selected separately
Voice AI agentSpeech recognition, scripted dialogue, speech synthesis. The call recording and transcript are posted to the conversation in the multichannel aggregator through its API
Stack is defined after the provider is selected

Phase 2. Internal perimeter

Operations AI agentZoho Inventory data and issuing assignments
hermes-agent, separate instance
Channel between agentsAn assignment from the internal perimeter to the external one. Only the operations agent initiates the call, and the response is the task status
A2A protocol
Zoho InventoryReads and permitted actions, authorization inside the internal perimeter
REST API, OAuth 2.0

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

EmailSending and receiving
Built-in Chatwoot channel
TelegramSending and receiving from a regular account, first message to a supplier
Custom integration service
ContactsMapping of supplier, items and communication channels
Depends on the company contact book

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

LevelWhat it verifiesHowWhen it runs
InvariantsContents of an assignment, access permissions, typed reading of results, no duplicate requests, item and quantity in a request matching the confirmed listAutomated tests, all must passEvery code change
StepQuality of a single AI step on a dataset with ground truthComparison with ground truth, LLM judgeEvery change to a prompt, procedure, tool or model; once a week on a schedule
ScenarioEnd-to-end run of the process on recorded historical supplier responses: the agent goes through the required steps and reaches the correct outcomeCheck of the final sheet and the action logBefore phase acceptance
ProductionReal employee tasksShare of corrections and escalations, sample reviewContinuously

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

StepPhaseWorst errorSafeguardMetric and threshold
Spec parsing1An item is missed: the customer receives an incomplete quoteReconciliation: every row of the document has become an item or is marked as unrecognized. An employee confirms the listItem recall at least 98%, field accuracy at least 95%. Against ground truth
Supplier search1No suitable supplier is found for an itemAn item without suppliers is flagged for an employeeA suitable supplier is found for 90% of items, at least 80% of those found are relevant. LLM judge
Supplier response parsing1A wrong price gets into the price comparison sheetA link to the message is stored next to the value. An employee checks the sheet before replying to the customerField 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 messages1The agent follows an instruction from a supplier messageInvariants: the external agent has no access to internal dataAll examples in the attack set pass. Based on the action log
Call parsing1.5A wrong price taken from the conversationDuring the trial period, an employee checks every recordingField accuracy at least 90%. Against ground truth
Low-stock item selection2An item is missed: the product runs out without a price requestAn employee sees the list of selected itemsRecall at least 98%, precision at least 90%. Against ground truth
Draft purchase order3A wrong price or quantity in the orderAn employee checks the order and sends it personallyAll 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

Historical specs with ground truth labelsExcel, Word, PDF; five complex documents: scans, merged cells, multiple tables. Labeling is done by a company employee. On the held-out third, the margin of error is about ±2.5%
30 specs, 750 items
Supplier responsesReal emails and WhatsApp messages, anonymized; including incomplete responses and refusals. Ground truth: price, batch size, lead time. On the held-out third, the margin of error is about ±2%
300 responses
Items with known suppliersItems from purchases over the last 6 months and the suppliers they were bought from. The dataset is not split, the margin of error is about ±8%
60 items
Attack setSupplier messages and response field values containing instructions aimed at expanding agent permissions and obtaining internal data. Prepared by the contractor; the set is extended with every new attack technique
40 messages
Call recordingsRecordings of conversations with suppliers and their transcripts. The margin of error is about ±13%: the dataset confirms that the step works, the threshold is confirmed by full manual review during the trial period
20 recordings
Zoho Inventory snapshotStock levels and item catalog as of a date, and the items an employee selected as low-stock. The margin of error is about ±2.5%
120 selected items
Historical purchase ordersOrders together with the correspondence they were based on
20 orders

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.