The problem
School social workers must log every service session in the state's special-education system, using a specific structure tied to IEP/504 goals. It's slow, repetitive writing, and the notes involve some of the most sensitive student information a district holds. Cloud AI was not an option.
The pipeline
I split the task into two model calls, so each step is small enough to check:
- Classify: choose which of 10 fixed CT SEDS service areas the session covered. The model may answer
NONE. - Draft: write the narrative using only the selected areas, following required phrasing rules.
Compliance rules are written into the system prompt as constraints:
"Refer to the child only as 'the student'. Never repeat a student name from the notes."
Push-in sessions also require an exact opening sentence, and the output is checked for it.
Failure-mode guards
Each guard targets a failure I actually observed:
- Option echo: small models sometimes "classify" by listing all ten options. Those replies are detected and thrown out.
- Forced choice: allowing
NONEstops the model from inventing an area just to answer. - Schema check + one corrective retry: invalid output gets one retry with specific corrective instructions; if that also fails, the partial draft is kept instead of losing the work.
- Model selection by name, so an embedding model can't be loaded by accident
How I verified it
- 50 XCTest cases covering prompt building, area selection, service-log rules, both backends and the clipboard
- Compared Apple Intelligence (~3s) with local Gemma (~15s) on output quality and shipped both behind one interface so the user can choose
- Privacy: notes are never written to disk, and copied text doesn't sync to other devices
- Iterated with a written
handoff.mdthat records each design decision for the AI agents building it
What this shows for AI training roles
- Naming a model's failure modes precisely and designing a check for each
- Breaking a task into steps that can each be checked
- Comparing models on speed and quality for a specific domain
- Turning regulatory requirements into prompt constraints