Commit a2fd5cd
fix(quiz): symmetric "fast" semantic across agent + legacy paths
Closes the asymmetry I flagged in the most recent review of PR #71.
Was: agent path "fast" → gemini-2.5-flash (upgrade), legacy path
"fast" → gemini-2.5-flash-lite (no-op). Same body field, different
models depending on which path ran. The kind of inconsistency that
surfaces six months later as "why does Fast sometimes feel slower
than Default?"
Now: agent path AND legacy fallback both use the same mapping
("fast" → flash, "smart" → pro, else → lite). _PREF_MODEL_NAMES is
the single source of truth on the agent side; the legacy
elif-chain in _legacy_generate_quiz mirrors it exactly.
Also:
- backend/routes/quiz.py: re-imported MODEL_DEFAULT alongside
MODEL_LITE/MODEL_SMART. Tightened the lazy-import comment in
_resolve_model_pref to describe the actual benefit (deferring
GoogleProvider construction to the first override request, not
import-path isolation — agents.quiz is already imported at module
top).
- docs/decisions/0013-refactor-2-quiz-shipped.md: addendum reworded
to "two independent layers, not multiplicative" — the env var sets
the agent's startup baseline; the body field, when present, fully
replaces it for the current call. Adds a paragraph documenting
the agent/legacy symmetry and pointing at _PREF_MODEL_NAMES as
the single source of truth.
Tests (TestQuizModelPref grew to 7)
- test_legacy_fallback_uses_default_when_pref_fast (NEW): pins the
symmetry — legacy "fast" must call gemini with MODEL_DEFAULT, not
MODEL_LITE. Asserts a clear failure message if anyone undoes the
fix.
- test_legacy_fallback_uses_lite_when_no_pref (NEW): pins the
default — no model_pref still uses MODEL_LITE (the cheap baseline
that's been there since the route shipped).
- Existing 5 tests unchanged.
Tests
- tests/test_quiz_routes.py: 30/30 (was 28, +2).
- Full backend suite: 533 passed, 3 pre-existing live-Supabase
failures unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ddd109b commit a2fd5cd
3 files changed
Lines changed: 87 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| |||
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
272 | 284 | | |
273 | 285 | | |
274 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| |||
0 commit comments