Zhen Wang

Solo project · Apr 2026 – present

UCSD Course Planning Agent

Design, code and evaluation · Live demo · GitHub

A language model is good at reading "I want to specialise in machine learning" and picking sensible courses. It is unreliable at the other half of the job: holding a 69-node prerequisite graph in its head. So in this planner the model does not get to decide whether a plan is legal. Code does.

Graph
69 nodes · 142 edges, parsed from prose
Context per query
8–13% of the catalog, not 100%
First-pass legality
40% 100%
Tests
27 unit tests · 9 validator fixtures

Reading a graph out of prose

Catalog text was never written to be parsed. "Prerequisite: DSC 20" and "Prerequisite for DSC 20" point in opposite directions; "accepted as an alternative to DSC 140A" is not a prerequisite at all, though an early version of my parser read it as one and inverted the edge. The parser is now direction-aware, handles AND-of-OR groups, seven substitution rules, and abstract requirements like "a probability course", and reports references it cannot resolve instead of dropping them silently.

Replacing the app's hand-maintained edge list with the parsed graph closed a 25-edge drift between two sources of truth that had been diverging for months.

In October 2026 I rebuilt the whole dataset against the official UC San Diego catalog — every department the graph touches, not just DSC. The stored prerequisite sentences had been hand-written, and a lot of them were wrong: DSC 80 was recorded as needing DSC 10 when it needs DSC 30 and DSC 40A, DSC 161's real prerequisites are not DSC courses at all, MATH 183 waits on MATH 20C rather than 20B, and the "probability course" group was missing half its options. Three parser habits of the catalog had to be handled before the rest fell out: a department carried over rather than repeated ("DSC 20/R and 40A/R"), a subject code written in mixed case ("Math 20C"), and a dash meaning a whole sequence ("MATH 20A-B-C"). Fixing the source text rather than the parser took the graph from 74 edges to 142, and a requirement a placement exam can satisfy is now recorded as exactly that instead of becoming a false edge.

Retrieval that respects structure

The first version stuffed 31 KB of catalog into every prompt. It now retrieves by embedding similarity and then expands one hop along the dependency graph, which brings 8–13% of the catalog per query and guarantees that a retrieved course's prerequisites are in context. Similarity alone misses them: DSC 40B is structurally essential to a question about DSC 100 and reads nothing like it.

The part that actually moved the number

A deterministic checker verifies ordering, unit caps, duplicates, concurrency exceptions and OR-groups, and returns which rule broke rather than a score. Asked for a whole multi-quarter plan in one shot, the model was legal 40% of the time across 20 planning tasks. Generating one quarter at a time against a recomputed eligible set took that to 100% — at 2.65 model calls per task against 1.90 for the one-shot version. The checker is itself regression-tested against nine plans with known verdicts, so a bug in the judge does not masquerade as a better model.

The checker, runnable

Below is a 12-course slice of the same graph, running the app's own rules. Press one-shot to see the whole plan proposed at once and checked edge by edge; press per-quarter to watch the eligible set get recomputed before each term. Click any course to see its prerequisites resolved. Every error string here is what validator.py actually prints.

Deterministic checker — runnable

Two ways to build the same four quarters.

Twelve required courses for the Data Science major, for a student who has already finished the first row. The rules are the app's own: ordering, AND-of-OR groups, abstract requirements such as a probability course, duplicates, and the twelve-unit full-time floor. Every verdict below is validator.py's own output, recorded from a real run.

Already completed

  1. Q1Fall

  2. Q2Winter

  3. Q3Spring

  4. Q4Fall

    Click any course to see its prerequisite groups resolved. Across the twenty-task evaluation suite, asking for a whole plan in one pass was accepted 40% of the time; rebuilding it quarter by quarter against a recomputed eligible set reached 100%. Those runs predate the October catalog correction, so the rates describe the method rather than this exact graph.

    What the evaluation actually says

    Two arms, same model, same 20 tasks, same validator. Numbers straight out of eval/results.json in the repo.

    Arm A asks for the whole plan, then repairs what the checker rejects. Arm B plans one quarter at a time against a recomputed eligible set.
     A — one-shot + repairB — per-quarter
    Legal on first pass8 / 20  (40%)20 / 20  (100%)
    Legal after repair14 / 20  (70%)20 / 20  (100%)
    Model calls per task1.902.65
    Violations left12 missing prerequisites · 3 under-full-time · 1 duplicatenone

    The row worth reading twice is the second one. Feeding violations back as a repair signal is not enough on its own — the one-shot arm still failed 6 of 20 after repair. What fixed it was removing the illegal choices before the model chooses, at a real cost: 2.65 calls per task against 1.90. The validator itself is regression-tested on nine plans with known verdicts, 9 of 9.

    What this is not

    • One department's catalog, parsed at one point in time. It is not an advising system and should not be trusted as one.
    • The 40% baseline is my own one-shot arm, not a published benchmark; both arms use the same model and the same 20 tasks.
    • No human evaluation — "legal" means the validator accepts it, not that a student would like the plan.

    Python · Gemini API (generation + embeddings) · RAG · NetworkX · Streamlit Cloud · pytest