Skip to content

Cache surplus practice blocks for instant delivery#72

Merged
sfw merged 1 commit intomainfrom
sfw/surplus-practice-cache
Mar 20, 2026
Merged

Cache surplus practice blocks for instant delivery#72
sfw merged 1 commit intomainfrom
sfw/surplus-practice-cache

Conversation

@sfw
Copy link
Copy Markdown
Owner

@sfw sfw commented Mar 20, 2026

Summary

  • When the LLM generates 2-3 practice_problem blocks, only the first is delivered — extras are cached as separate GeneratedContent entries via SurplusPracticeCache
  • On the next continue request, cached surplus blocks are served instantly before falling back to LLM generation, eliminating wait time
  • Surplus entries use is_predictive_warm: true to piggyback on existing mastery-change invalidation — no changes to invalidation infrastructure needed

Test plan

  • 12 new unit tests covering split logic, cache/pop ordering, session isolation, invalidation flags, and TTL
  • Backend tests: 733 passed
  • Frontend tests: 289 passed
  • Backend lint clean
  • Frontend lint clean
  • Frontend production build passes
  • Manual: verify only 1 practice question appears per page
  • Manual: verify next question loads instantly from surplus cache

🤖 Generated with Claude Code

When the LLM generates multiple practice_problem blocks, only the first
is delivered to the learner. Extra blocks are cached and served instantly
on the next continue request, eliminating wait time while the next eager
generation runs in the background. Surplus entries piggyback on the
existing predictive warming invalidation via is_predictive_warm flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sfw sfw merged commit b04a76c into main Mar 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant