CS 378: Building AI Agents - Spring 2027
Course Description
An agent is a model with a harness around it. The harness is the loop, tools, memory and checks that turn a component that is sometimes wrong into software you can ship. The model is the one part you don't control, and it has two limits the harness has to cover for. It makes mistakes, so the harness has to catch what it can't prevent. It also knows nothing beyond its training data, so the harness has to hand it the knowledge each question needs, ranked and restricted to what the asker is allowed to see. This course is about the engineering that covers for those two limits.
Topics:
- Tool calling and structured outputs inside the agent loop, with a receipt for each mutation and answer.
- The knowledge layer: Assembling context from schemas, catalog metadata, lineage, pipeline code, documents, tickets and messages when the company doesn't fit in the window. Ranking that evidence by how authoritative and recent it is and where it came from. Showing contradictions to the asker and enforcing the asker's permissions on unstructured knowledge.
- Harness failure shapes: unpersisted state, overlapping writers, deadlines and cancellation, context and cost drift, approval drift, unverified delivery.
- Knowledge failure shapes: stale sources, authority inversion, definitional conflict across teams, unresolved internal vocabulary, curated-but-wrong instructions, leaks through unstructured sources, context flooding.
- Model failure modes: fabrication, plausible-but-wrong SQL, silent ambiguity resolution, sycophancy, miscalibration, long-context degradation, judge bias. How to attribute and contain them.
- Cost visibility: pricing every model call (tokens) and query (bytes scanned) in dollars, then cutting duplicate work to keep an agent inside a budget.
- Evaluation: evals before code, golden questions, result-based judges, evidence recall, item analysis, reward hacking.
- Security: prompt injection and tool poisoning through data and knowledge sources, and the exfiltration that follows, treated as authority failures. Defenses include bounded authority, pass-through permissions, dynamic risk scoring and sandboxing.
- Compounding failures in multi-agent and long-horizon systems.
- Agent-written memory as a knowledge source, and the run receipt audit.
Learning Outcomes
By the end of this course, students will be able to:
- Build an agent harness without a framework, starting from a bare model-call loop in the OpenAI SDK and adding tool calling and structured outputs, with a receipt for every mutation.
- Use a run's receipt to attribute a failure to the model, the harness, the data or the knowledge the run relied on.
- Reproduce each harness failure shape and build a detector and fix for it, documented as a catalog entry (trigger, symptom, detector, fix, receipt fields).
- Measure how often each model failure occurs and build containment that keeps it from reaching the asker.
- Explicitly resolve which metric, entity and time period a question means, then assemble a ranked evidence bundle for it from schemas, catalog, lineage, pipeline code, documents, tickets and messages.
- Build a knowledge layer over mixed enterprise sources that ranks evidence, resolves internal vocabulary before writing SQL, shows definitional conflicts to the asker and returns only what the asker is entitled to see.
- Run queries safely against BigQuery using dry runs, byte limits, timeouts and cancellation, with permissions resolved before anything is retrieved or executed.
- Instrument model calls and queries for tokens, bytes scanned, latency and cost, and keep an agent inside a fixed budget.
- Design a golden-question benchmark graded on result sets and evidence recall. Check its quality with item analysis and judge-human agreement, and defend it in a dispute process.
- Attack an agent with prompt injection and tool poisoning delivered through data and knowledge sources, then defend it with sandboxing and scoped, time-bounded authority.
- Run an agent unattended on live questions, then audit the run. For every incident, say what woke the agent up, what state it inherited, what authority it used, what knowledge it relied on (and whether that knowledge was current and authorized for the asker), what executed, what evidence survived, and whether the model or the harness failed.
Prerequisites
CS 439 (Principles of Computer Systems) or equivalent, and working SQL. No prior machine-learning coursework is required.
Required Reading
- OpenAI API reference for chat completions, function calling, and structured outputs. Links to be posted.
- Designing Data-Intensive Applications by Martin Kleppmann (O'Reilly, 2026), chapters on reliability, consistency, and transactions.
- Additional readings to be posted.
Course Communication Tools
We will be using the following tools throughout the term:
- Canvas for milestone and participation submissions and grade reporting.
- Ed Discussion for announcements, questions, and answers.
- GitHub for the course code snippets, including the warehouse generator, the reference knowledge-search tool, the class failure catalog, and team repositories.
- Zoom for online office hours.
Tech Stack
Our primary tech stack will consist of the following:
- OpenAI Python SDK, pointed at Vertex AI's OpenAI-compatible chat-completions endpoint.
- Gemini Flash-Lite as the class model called through the OpenAI SDK.
- BigQuery as the warehouse and the source of query provenance, scan-cost accounting (bytes billed), dry runs, row-level security, authorized views, and search indexes over the knowledge corpus.
- Data Build Tool (dbt) for the pipeline models that define the warehouse's metrics.
- Cloud Run to deploy the agent and Cloud Storage for the raw ledger files.
- SQLite for the agent's own persisted state and receipts.
Our development infrastructure consists of the following tools:
- GitHub for version control and code repositories.
- VS Code (and an optional coding agent of your choice for development).
- The Google Cloud console and gcloud CLI.
Google Cloud Credits and Costs
Each student will receive $50 in Google Cloud credits for the semester through Google's credits-for-teaching program, applied to your Google Cloud project. The course is designed so that the credits cover the cost of the semester.
The Warehouse
All teams will work on the same dataset: the books of Harlow Design Co., a synthetic design studio with about forty clients and three years of history, together with the studio's knowledge about itself: its org directory, chat channels, project tickets, versioned documents and skill files, contracts, and CRM. The warehouse is generated from a clean ground truth, with specific ambiguities and defects introduced on purpose, and every message, ticket, and document is derived from that truth so its accuracy and staleness are known. The knowledge corpus is about two million tokens, roughly twice the class model's context window, so no agent can read all of it and every agent must choose. Because every team sees the same data, each failure shape has the same form for the whole class and golden-question scores are comparable across teams.
Term Project
The coursework centers on one semester-long project: an agent that answers Finance's questions against the Harlow warehouse. The answers have to be correct, backed by evidence, within each asker's permissions and free of the harness failures. More specifically:
- You will work in teams of 2–3, formed during the first week of class. Every team builds its own harness.
- You will write your evals before your agent. The evals are a set of questions with expected result sets that your agent must pass, drawn from four task families (lookup, diagnosis, reconciliation and resolution).
- You will build the agent from a bare model-call loop using the OpenAI SDK, with a receipt for every mutation and a provenance receipt for every answer that names the knowledge the answer relied on.
- You will build the agent's knowledge layer. It retrieves from the Harlow corpus, ranks evidence by how authoritative and recent it is and where it came from, detects contradictions and applies the asker's entitlement at retrieval time. The course provides the search index, and your team builds the ranking and the permission filter.
- You will author a golden-question set with expected result sets, along with an automated judge. The judge executes the agent's SQL and compares the results, then checks that the controlling source appears in the provenance receipt. Your agent is run against every other team's set, and theirs against yours.
- You will deploy the agent to the cloud and run it unattended against a stream of live questions from the teaching staff, including questions designed to trigger each failure shape.
The project is divided into 5 milestones (M1–M5), each producing a concrete deliverable:
- Milestone 1: Project proposal with evals sketched, naming your knowledge sources and ranking signals and your approach to permissions (week 3)
- Milestone 2: Evals written across all four task families, no agent code yet (week 5)
- Milestone 3: Working agent passing its own evals (week 9)
- Milestone 4: Golden-question set published and cross-team scoring complete, graded on result sets and evidence recall (weeks 10–12)
- Milestone 5: Unattended run, run receipt audit, final demo and report (weeks 13–14)
Milestones are due at
11:59pm on the Sunday following the week in which they appear on the schedule.
Failure Catalog
Each reproduction from weeks 5–10 is also submitted as an entry in the class failure catalog. An entry gives the trigger, the symptom as the asker sees it, the attribution (model, harness, data, knowledge or mixed), the detector that catches it, the fix and the receipt fields that would have made it visible. For a model failure, the fix is the containment, reported with the failure rate before and after. Every team works with the same warehouse and the same model, so the catalog can show how often the bare model falls into each trap and how many independent harnesses exhibited or contained it. It also shows which detectors carried over to harnesses they were not written for. Golden-question authors draw their failure-shape questions from the catalog.
Quizzes
There will be quizzes on most weeks, based on the assigned readings and milestone submissions. The quizzes will be done in class, and students are expected to take them by themselves.
Design Reviews
Teams participate in at least two live design reviews during the term. You should be prepared to answer impromptu questions and clearly explain the design of your harness, your evals, your knowledge layer, and the state of your project, including walking through the evidence bundle for one question and defending why one source outranked another.
Class Participation
Students are expected to actively participate in in-class code labs, the week-8 stuff-vs-rank lab, the week-12 red team/blue team exercise on the shared warehouse, and the golden-question dispute process on Ed.
Grading Breakdown
- Term Project: 40%
- Milestone 1 (project proposal with evals sketched)
- Milestone 2 (evals before code)
- Milestone 3 (working agent)
- Milestone 4 (golden-question quality and cross-team scoring)
- Milestone 5 (unattended run, audit, final demo and report)
- Quizzes: 20%
- Design Reviews: 10%
- Participation: 10%
- Final Exam: 20%
The final mapping to letter grades will be determined at the end of the term once all coursework has been graded, and will be based on the overall distribution of scores.
Academic Integrity
This course will abide by UTCS' code of academic integrity.
Generative AI Policy
This course is about building AI agents, and you will use language models throughout it. Using AI is required, and studying where it fails is graded. That said, the goal is still for you to understand every line you submit and every answer your agent gives.
You may use generative AI to:
- Write, refactor, and test harness code, retrieval and ranking code, detectors, judges, and fixtures.
- Generate candidate golden questions and test data, which you then verify against the ground truth you can see.
- Brainstorm, look up API and SQL details, and debug.
- Draft catalog entries and reports, which you then verify against your own receipts and transcripts.
You may not use generative AI to:
- Submit code you cannot explain. During design reviews and class discussions, "the agent wrote it" is not an acceptable answer.
- Fabricate a failure reproduction, detector result, or audit finding. Every catalog entry and every line of the run receipt audit must correspond to something you ran and observed. Submitting an unverified AI-generated account of a run is a direct violation of academic integrity.
- Obtain or reconstruct the held-out ground truth for the warehouse or the knowledge manifest by any means other than analysis of the data you are permitted to see.
Late Submissions and Extensions
You will receive a total of 5 slip days for the semester, which can be used for quizzes, participation, and project milestones.
- Each slip day used extends a deadline by 24 hours with no penalty, up to a maximum of 3 days late.
- Because milestones are team deliverables, a late milestone submission deducts slip days from every team member.
- Slip days are applied automatically based on your submission timestamp in Canvas. You do not need to notify the teaching staff.
- The golden-question deadlines in weeks 10 and 12 cannot be extended with slip days, since other teams depend on them.
Once you have used all 5 slip days, you will need a doctor's note (or equivalent documentation) to receive an extension. Without proper documentation, late submissions incur a 10% grade penalty per day, up to a maximum of 3 days late, after which the submission receives a zero.
Students with Disabilities
If you are a student with a disability, or think you may have a disability, and need accommodations, please contact Disability and Access (D&A). Contact and more details are available on D&A's website.
If you are already registered with D&A, please share your accommodation letter with me as early as possible in the semester so we can discuss how your approved accommodations will be implemented in this course.
Week-by-week Schedule
This schedule is tentative and may change based on the needs of the class. Dates will be added from the Spring 2027 academic calendar.
| Week |
Reading |
Topic |
Project Milestone |
| 1 | TBD | Model failures vs. harness failures: harness failures are bugs, model failures are rates. The loop and its non-determinism. The proposes/commits/proves model. Attributing a failed run from its receipt. | Teams formed |
| 2 | TBD | The bare loop: tool calling, structured outputs, stop conditions and the first receipt. The analyst loop vs. the one-shot query. | |
| 3 | TBD | The knowledge layer. Why enterprise data is harder for models than code. Sources and how far to trust them. The evidence bundle. Keyword search over the Harlow corpus. When to search and when to read the pipeline models. | M1: project proposal with evals sketched |
| 4 | TBD | Frameworks and protocols: what frameworks hide and where they fail. Curated knowledge: skills and agent-instruction files as a directory that is stale and contradictory, with nothing ranked. | |
| 5 | TBD | State that was never persisted: how events enter and how state is rehydrated. Who owns persisting the turn. | M2: evals written across all four task families, no agent code yet |
| 6 | TBD | Overlapping writers: idempotency, locks, ordering, single-writer lanes. | |
| 7 | TBD | Time: deadlines and cancellation. Tools as unreliable services, with retries and partial failure. | |
| 8 | TBD | Context as a memory hierarchy. Ranking signals: authority, recency, published vs. draft, system of record over chat. Knowledge failure shapes: stale source, authority inversion, definitional conflict, flooding. Cost visibility: scan cost vs. token cost, caching, duplicate queries, model routing. | |
| 9 | TBD | Approval drift and bounded authority: pass-through permissions, row-level security, authorized views, least privilege. Permissions on unstructured knowledge: channel membership and document ACLs as pass-through, and the agent's service account vs. the asker's entitlement. | M3: working agent passing its own evals |
| 10 | TBD | Internal success vs. user-visible proof. Failure detection in production. | Golden-question set draft published |
| 11 | TBD | Evaluation: golden questions, result-based grading, evidence recall, judge validity, saturation, reward hacking, item analysis. | |
| 12 | TBD | Security week: prompt injection and tool poisoning through data and knowledge sources (ticket comments, messages, documents), and the exfiltration that follows, treated as authority failures. The knowledge layer as an attack surface. Red team/blue team exercise on the shared warehouse. | M4: cross-team scoring complete |
| 13 | TBD | Compounding failures in multi-agent systems and long-horizon runs. Agent-written memory as one more stale, un-ranked knowledge source. | |
| 14 | TBD | The run receipt audit: what woke the agent up, what state it inherited, what authority it used, what knowledge it relied on (and whether that knowledge was current and authorized for the asker), what executed, what evidence survived, and whether the model or the harness failed. | M5: final demo and report |
Acknowledgments
This course grew out of conversations with several colleagues in the department, among them Alison Norman and Glenn Downing. It also draws from Vinoth Govindarajan's AI Engineer 2026 talk The Model Was Right. The Harness Failed. AI and cloud computing resources are provided through the generous support of Google.