KatalockAi AcademyBack to KatalockAi
Phase project, required for the Phase 13 certificate

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.

about 6 h Reviewed against a 6-point rubric
Submit your project Get coached by Professor Katalock

Lessons this project uses

  1. 1The Tool Interface - Why Agents Need Structured I/OPhase 13: Tools and protocols
  2. 2Function Calling Deep Dive - OpenAI, Anthropic, GeminiPhase 13: Tools and protocols
  3. 3Parallel Tool Calls and Streaming with ToolsPhase 13: Tools and protocols
  4. 4Structured Output - JSON Schema, Pydantic, Zod, Constrained DecodingPhase 13: Tools and protocols
  5. 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

  1. 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).
  2. Registry. At least 6 tools, each with name, description, JSON Schema input, executor and a consequential flag. Write two versions: registry_v1 (vague descriptions, loose string types, one monolithic action tool) and registry_v2 (snake_case verb-noun names, "Use when X. Do not use for Y." descriptions, enums, ID patterns, additionalProperties: false, atomic tools). Write a small linter for the lesson 05 rules and show it flags v1 and passes v2.
  3. Agent loop. Uses the chat-completions tools interface 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.
  4. 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.
  5. Typed final answer. The final answer must validate against a JSON Schema you define (for example {answer, order_ids, tools_used, needs_human} with additionalProperties: false). Classify each failure as parse error, schema violation or refusal (lesson 04), allow at most one repair retry, and never retry a refusal.
  6. Eval set. At least 25 queries in eval/queries.jsonl, each labelled with the expected tool(s) or none. 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.
  7. 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.
  8. 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_v2 into 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.

CriterionWeightHow it's checked
Agent loop correctness25Code validates arguments before execution, returns teaching error messages, enforces a turn limit, gates consequential tools, and correlates parallel results by tool_call_id; offline tests for these pass.
Schema design and linting15registry_v2 follows lesson 05 rules (names, Use when / Do not use for, enums, patterns, additionalProperties false, atomic tools); the linter output shows v1 flagged and v2 clean.
Structured output and parallelism15Final answers are validated against a JSON Schema with parse, schema and refusal outcomes classified and at most one repair; the benchmark shows sequential vs parallel wall-clock.
Eval results20queries.jsonl meets the size and mix requirements; ab.json reports the listed metrics for both registries on the same model with a per-query table consistent with the pasted summary.
Code quality10Backend, registries, loop and eval harness are separate; endpoint and key come from environment variables; no keys committed.
README and reflection15README documents how to run, the model used, the A/B table, limitations of the small eval, and analyses two remaining failures.

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.