Quest 01 / 03 · Project
Build a typed ticket-triage agent on Ollama and grade it with Promptfoo
- Pydantic AI
- structured outputs
- local LLMs
- prompt evaluation
- pandas
Why now The week's Pydantic AI review says the library validates agent output but leaves business correctness to application checks. Hugging Face's new agent-evaluation guide follows an evaluation from its claim through task design and grading to the reported score. Labeled support tickets let a reader supply that missing check with a local model and an open test suite.
Build it A Python agent reads a support email and returns a validated object with a queue, a priority and a draft reply, using a model served by Ollama on your own machine. A Promptfoo suite scores the queue and priority choices against the dataset's labels.
From the news
- Pydantic AI puts typed boundaries around agent work 2026-11-26 · source
- Promptfoo keeps application security tests close to development 2026-11-26 · source
- Ollama makes model serving part of the developer workstation 2026-11-26 · source
- Hugging Face publishes a guide to agent evaluation 2026-11-23 · source
Tools
- Pydantic AI
Pydantic AI uses the MIT license and is free to use. Model providers, deployment infrastructure and optional Pydantic commercial services have separate terms and costs.
- Ollama
Ollama's runtime uses the MIT license, while model weights have their own licenses. Local execution has no Ollama usage charge; optional cloud inference uses metered credits, subscriptions and enterprise terms.
- Promptfoo
Promptfoo's open-source code is MIT licensed. Its Community plan is free with stated probe allowances; commercial Enterprise and on-premise offerings add features under separate service terms. Model-provider charges and additional enterprise probes can be separate costs.
Data
- Customer IT Support - Ticket Dataset Kaggle
Labeled email tickets with queues, priorities and agent answers supply the agent's inputs, the ground truth for grading and the reference replies.
Steps
- Download the ticket dataset, load it in pandas and inspect the columns to find the ticket text, the queue label, the priority label and the agent answer.
- Keep one language to start, drop rows missing a queue or priority, and hold out 300 tickets with a fixed random seed before you write any prompt.
- Install Ollama, pull a small instruction model that supports tool calling and fits your memory, and confirm the local API answers a test request.
- Define a Pydantic output model whose queue and priority fields are enums built from the labels in the training split, plus a free-text reply field.
- Write a Pydantic AI agent that calls the Ollama endpoint with the ticket text, returns that model and retries once when validation fails.
- Give the agent one tool that returns the three most similar training tickets with their labels, using TF-IDF similarity from scikit-learn.
- Export the held-out tickets as Promptfoo test cases and write a config that calls your agent through a Python provider with equality assertions on queue and priority.
- Run the suite once with the similar-ticket tool and once without it, and keep both result files.
- Add a model-graded rubric, with your Ollama model set as the grader, that compares draft replies with the dataset's agent answers on 50 tickets, then read 10 of its verdicts yourself.
Deliverables
- A repository with the agent package, the Promptfoo config and the held-out test file, crediting the dataset as its license requires.
- A results table comparing the runs with and without the similar-ticket tool.
- A short write-up of the five most frequent queue confusions with an example ticket for each.
How to measure it
Queue accuracy and macro F1 on the 300 held-out tickets, compared against a majority-class baseline and a TF-IDF logistic regression trained on the same split. The agent earns its place only if it beats the logistic regression on macro F1.
Done when
- The agent returns a validated object for at least 295 of the 300 held-out tickets, and the log records every validation retry.
- Promptfoo reports queue accuracy and priority accuracy for both runs on the same 300 tickets.
- A confusion matrix of queue labels is saved as an image beside the results.
- The README lists the Ollama model name and tag, the random seed and the exact Promptfoo command.
- Ten hand-checked rubric verdicts are recorded with a note on whether you agree with each one.
Stretch goals
- Run Promptfoo's red-team plugins with tickets that try to talk the agent into a different queue, and report how many succeed.
- Swap in a second local model and compare accuracy against seconds per ticket on the same hardware.
- Repeat the evaluation on a second language from the dataset and report whether the similar-ticket tool helps more or less.
