Order Desk Agent with a Tool Schema A/B Eval
Build a function-calling agent loop for a small shop's order desk with validation, parallel calls and typed final output, then measure how much rewritten tool schemas improve selection accuracy.
Lessons this project uses
- 1The Tool Interface - Why Agents Need Structured I/OPhase 13: Tools and protocols
- 2Function Calling Deep Dive - OpenAI, Anthropic, GeminiPhase 13: Tools and protocols
- 3Parallel Tool Calls and Streaming with ToolsPhase 13: Tools and protocols
- 4Structured Output - JSON Schema, Pydantic, Zod, Constrained DecodingPhase 13: Tools and protocols
- 5Tool Schema Design - Naming, Descriptions, Parameter ConstraintsPhase 13: Tools and protocols
What You'll Build
A customer-support agent for a small online shop (your own invented or real catalogue) that answers questions by calling tools: order status, product search, stock, shipping estimate, and a consequential refund tool behind a confirmation gate. You own the whole describe, decide, execute, observe loop from lesson 01, including argument validation, parallel execution of independent calls, and a schema-validated final answer. Then you run an A/B eval: the same model with a sloppy tool registry (v1) and a registry rewritten with lesson 05 rules (v2), on a labelled query set you write.
Requirements
- Backend. An in-memory or SQLite shop with at least 15 orders and 20 products in your own data. Each tool executor adds a simulated latency (for example 200 to 800 ms).
- Registry. At least 6 tools, each with name, description, JSON Schema input, executor and a
consequentialflag. Write two versions:registry_v1(vague descriptions, loosestringtypes, one monolithicactiontool) andregistry_v2(snake_case verb-noun names, "Use when X. Do not use for Y." descriptions, enums, IDpatterns,additionalProperties: false, atomic tools). Write a small linter for the lesson 05 rules and show it flags v1 and passes v2. - Agent loop. Uses the chat-completions
toolsinterface of any OpenAI-compatible endpoint. Validates every call's arguments against the schema before execution; invalid arguments return an error message written to teach the model (with an example) instead of raising. Hard turn limit (5 or fewer). A consequential tool is never executed without confirmation; in eval mode the gate auto-denies and logs the attempt. - Parallel calls. When the model emits several tool calls in one turn, run them concurrently (thread pool or asyncio) and return results correlated by
tool_call_id. Include a benchmark that runs the same three independent calls sequentially and in parallel and reports both wall-clock times. - Typed final answer. The final answer must validate against a JSON Schema you define (for example
{answer, order_ids, tools_used, needs_human}withadditionalProperties: false). Classify each failure as parse error, schema violation or refusal (lesson 04), allow at most one repair retry, and never retry a refusal. - Eval set. At least 25 queries in
eval/queries.jsonl, each labelled with the expected tool(s) ornone. Include at least 5 that need no tool, at least 5 near-miss cases where two tools look plausible, and at least 3 that need two independent calls. - A/B results. Run v1 and v2 on the same model and settings. Report tool-selection accuracy, argument-validity rate, schema-valid final answer rate, average turns, and blocked consequential attempts, per registry, in
results/ab.json. Include a per-query table so a reviewer can see which queries flipped. - Offline mode. A scripted fake decider (as in lesson 01) lets the loop and tests run with no model; tests cover validation, the turn limit, the confirmation gate, id correlation, and final-output classification.
Constraints
- Any OpenAI-compatible chat endpoint works (a hosted provider, the KatalockAi API, or a local server such as Ollama, llama.cpp server or vLLM). Read the base URL, model name and key from environment variables; never hard-code a key and never require one specific commercial provider. A small local model that supports tool calls is enough; say which model you used and note that results depend on it.
- Runs on a laptop CPU. The eval should be under a few hundred model calls.
- Python or TypeScript. You may use an OpenAI-compatible client SDK, but not an agent framework that hides the loop.
Stretch Goals
- Stream the model's tool-call arguments and reassemble them per call id without parsing early (lesson 03).
- Translate
registry_v2into the Anthropic and Gemini declaration shapes and show one canonical call extractor (lesson 02). - Run the A/B on a second model and compare how much the schema rewrite matters for each.
How to Submit
Public GitHub repo with README.md, agent.py, registry_v1.py, registry_v2.py, eval/queries.jsonl, run_eval.py, tests/, and results/ab.json. The README must say how to run the offline tests and the live eval (which env vars to set), which model and endpoint type you used, the A/B table, the parallel benchmark, and a reflection on two queries that v2 still gets wrong and why. Paste the eval summary and test output when submitting.
How It's Reviewed
Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.
Submit
Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.
- Terminal output of run_eval.py for both registries, including the summary table
- Contents of results/ab.json (or its summary section)
- Linter output on registry_v1 and registry_v2
- Output of the parallel vs sequential benchmark
- Full output of the offline test run
- Model name and endpoint type used (no keys)
Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.