网页
综合
更新时间 2026-10-01 11:46:08
The fries are gluten-free. The fryer isn't. An allergy agent that only works because the menu is a graph - DEV Community
自动蜘蛛
dev.to
正文约 6000 字
Posted on Oct 1 • AI-assisted
Sanity Challenge Path One Submission
This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content
Olive & Ember Allergy Concierge: an AI agent for a (fictional) Mediterranean grill in Dublin that tells guests with food allergies what they can actually eat, why, and what the kitchen can change to make a dish safe.
Ask a normal menu chatbot "are the fries gluten-free?" and it reads "Skin-on fries, sea salt" and says yes. It's wrong. The fries share Fryer 1 with battered cod, calamari and chicken goujons. A coeliac guest needs the swap to the gluten-free fries from the dedicated Fryer 2. That fact isn't in any description. It lives in a relationship: component → prepared on → shared equipment ← other components → ingredients → allergens.
The menu has plenty of these traps, all modelled rather than written down:
Guests tick their allergies (the 14 EU allergens) and diet, then ask in plain language. The agent answers with dish cards, and each card's verdict (safe, safe with changes, caution or unsafe) is computed from the content graph, not by the AI.
Live: https://olive-ember-allergen-agent.vercel.app
One-click demos (each link preselects the allergies and asks the question):
Each answer shows a trace of what the agent actually looked up (Queried menu graph → Read kitchen guidance → Verified N dishes), then groups the dishes into Safe as served, Safe with a change (with the exact "Ask the kitchen to…" fix) and Not for you today.
Answers take 30–90 seconds on the free Gemini tier.
An AI allergy concierge for a (fictional) Mediterranean grill in Dublin. Guests pick their allergies and diet, ask questions in plain language, and get answers grounded in the restaurant's structured menu graph in Sanity plus a Sanity Context Knowledge Base of kitchen procedures and UK Food Standards Agency guidance.
Live demo: https://olive-ember-allergen-agent.vercel.app Public dataset: project a2iy46w2, dataset production (public read, e.g. all dishes)
Built for the DEV Sanity Challenge, Path One. Not medical or dietary advice.
"Is this dish safe for me?" can't be answered from menu prose. The fries have three clean ingredients, yet they are not gluten-free: they share Fryer 1 with battered cod and calamari. The Caesar is gluten-free only once the croutons are left off. The "vegan-looking" cauliflower has honey in its dressing. Those answers only exist as relationships:
Six schema types in Sanity Studio: dish, component (sub-recipe), ingredient, allergen, equipment and guidanceArticle.
The seed has 14 allergens, 87 ingredients, 51 components, 8 stations and 25 dishes.
A Context endpoint with a dataset source serves GROQ tools and ignores Knowledge Base sources. So the agent connects to two endpoints:
The Knowledge Base is built from two sources:
The build turned these into 10 cited entries. It also caught a real conflict: my article said "112 in the EU" while the entry said "999 or 112". Resolving that is what made me pin the restaurant to Dublin, where both numbers work.
Tools the agent uses:
Here's the kind of query the agent writes on its own:
Safety is too important to leave to a language model's reading of a JSON blob. The same graph feeds a small pure function (evaluateDish). It rolls up contains, may contain and cross-contact, checks the diet against animalOrigin, and then searches the dish's removable components and substitutions for the smallest set of changes that makes it safe.
In testing, before I added verify_dishes, the agent told a peanut-allergic guest to avoid the falafel. The graph knew the peanut risk came only from the tahini sauce, which can be left off. With the tool, the agent's text and the card now agree: safe with changes, no tahini.
The GROQ filter and domain instructions for each endpoint live in the Context app, not in code. The kitchen's procedures live as ordinary Sanity documents that feed the Knowledge Base. When a chef changes a recipe or moves a dish to another fryer in the Studio, the next answer reflects it. There's no re-embedding and no prompt edit.
The whole project was built in one session with Claude Code: challenge research, schema design, seed data, both Context endpoints and the Knowledge Base, the agent, the deployment and this post.
<task-notification> <task-id>ac78a8f7d51fccdff</task-id> <tool-use-id>toolu_016vJSdtnAdcgxSCfBn6DNkJ</tool-use-id> <output-file>[REDACTED]\AppData\Local\Temp\claude\C--Users-user-Desktop-sanity-challenge\23523501-313e-42ee-84b3-7aed61500188\tasks\ac78a8f7d51fccdff.output</output-file> <status>completed</status> <summary>Agent "Seed data + guidance articles" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>The seed data is written and the offline validator passes. seed.ts hasn't run yet; it needs the Sanity project and a write token first.
Files (all under studio/scripts/): - data/: helpers.ts, allergens.ts, ingredients.ts, equipment.ts, components.ts, dishes.ts, guidance.ts, index.ts (exports allDocuments in the order they must be seeded) - seed.ts: idempotent createOrReplace, written in chunks of 100, with a clear error if env vars are missing - validate-data.ts: runs offline
Counts: 196 documents in total.
I went over your targets on components (~30–35) and dishes (20–24). The extra halloumi salad puts the orphaned za'atar, capers and dressing to use.
Teaching cases: - Honey: charred-cauliflower is vegan only if the harissa dressing comes off. - Hidden nuts: flame-grilled-vegetables has romesco (tree nuts, plus gluten and sulphites). - Croutons: ember-caesar is gluten-free only with the croutons removed. - Supplier may-contain: vegan-chocolate-pot may contain milk and tree nuts (dark chocolate) and gluten (oat crumble). - Unavailable: garlic-prawns. - Shared fryer: plain fries have clean
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。