Skip to content

Case 05 / Retail sales agent · inherited codebase

Randy

A consultative sales agent for a Vietnamese electronics retailer, inherited as a teammate's hackathon build and re-architected until every SKU, every price and every PC build came from server code instead of the model.

RoleInherited build — re-architect, harden, ship
Status● live · 6 stress rounds held
Tests327 passing, from 44
StackVercel Functions · OpenAI Responses API · Supabase
randy — phongvu sales agent200 OK
Randy — sales agent panel beside the storefront

The rule

The model writes the sentence. It never picks the SKU, the price, or the part — and it can never narrate something the server did not actually render.

Build notes

Grounded by construction

Search, comparison and PC building are server-side tools over an 11,865-SKU catalog. The reply and the product cards are rendered from one tool result, so the prose cannot contradict what is on screen.

Six adversarial rounds

Bilingual shopper agents attacked it for 400+ live turns: jailbreaks, haggling, forged history, absurd budgets. All refused. Two of four reported "criticals" turned out not to be real — findings get re-verified offline before anything is changed.

Guards on the output

Five rounds of prompt rules stopped converging, so a finding-rate analysis moved the checks onto what actually ships: owned parts cannot be re-billed, build totals are re-derived, and a comparison that never rendered cannot be described.

The catalog is the product

The full catalog ships on disk instead of paging from a Tokyo Postgres on every cold start — 20s down to ~5s, PC builds 5s down to ~470ms — with an EN↔VI vocabulary so English category words still reach a Vietnamese catalog.

More screens

Randy's PC build sheet for a 25M VND gaming budget: CPU, RAM, SSD, GPU, PSU and case rows each with a Swap button, a 24,918,000 VND total under budget, and socket, RAM and PSU compatibility checks
Randy comparing four gaming laptops side by side across storage, display, graphics and pros/cons rows, with specs missing from the catalog marked "Needs checking" rather than guessed, closing on a recommendation that cites price and warranty