Conversation
… override
Three changes that together let the AI use multiple themes per video
without blowing up API costs.
Prompt caching (cost):
- Anthropic client extended to accept system as a SystemSegment[] with
per-segment cache_control. The planner builds 4 cache breakpoints,
ordered most-stable to most-volatile:
1. RETENTION_PLAYBOOK ~3-5k tokens, every video reuses
2. Active theme DESIGN_SYSTEM.md ~1-2k, same theme reuses
3. DESIGN.md + DESIGN-ART.md + ~1-2k, same project reuses
RESEARCH.md
4. Fidelity rule (per call) small, never cached
- Schema-correction retry and no-scenes retry now append to the USER
message instead of mutating the system prefix, so the cached blocks
stay valid and retries hit cache too.
- Net effect: ~80% input-cost reduction on iterative work after the
first plan (re-plans, retries, hook critic share the same prefix
inside the 5-minute cache TTL).
Multi-theme awareness:
- Studio API passes a CONDENSED list of every other installed theme to
the planner: id + 1-line description + their preference arrays only
(~50 tokens per theme). Stays inside the active-theme cache
breakpoint so adding a new theme doesn't invalidate the cache for
projects that don't use it.
- Planner gains a "Other themes available for cross-pollination"
section explaining how to borrow concepts.
Per-scene theme override:
- Planner tool schema gains scene.themeOverride (validated against
availableThemes + the active theme).
- Materializer threads it through as scene.props.theme.
- Assembler render loop honours scene.props.theme; when set the scene
uses THAT theme's tokens for template render + atmosphere injection.
- Lets the planner mix concepts (e.g. a Dreamspace hook in a
HackerNoon-themed video) with one prop.
Documentation:
- docs/design-systems/README.md gets sections on mixing themes per
scene, sourcing themes from Claude design (Remotion + Babel) where
JSX is reference and HTML+GSAP is production, and the cost-control
cache strategy.
cuio
pushed a commit
that referenced
this pull request
Apr 25, 2026
Resolves conflicts with PR #14 (prompt caching + multi-theme awareness + per-scene theme override). Both feature sets are kept — themes can ship templates AND the planner gets cached + multi-theme aware. Conflict resolutions: - planner.ts PlanOptions: kept both availableThemes (PR #14) and availableTemplates (PR #15) fields. - planner.ts call site: kept the cache-controlled SystemSegment[] build from PR #14 + the templateRegistry threaded through to buildToolDefinition from PR #15. - studio-api/routes/script.ts: pass BOTH otherThemes (peer-theme cross-pollination) AND availableTemplates (theme-shipped templates) to planScript. - docs/design-systems/README.md: merged the 'Mixing themes per scene' + 'Themes from Claude design' + 'Cost notes' sections from PR #14 with the 'Theme-shipped templates' subsystem doc from #15.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three changes that together let the AI use multiple themes per video without blowing up API costs.
1. Prompt caching — ~80% input-cost reduction on iterative work
Anthropic client extended to accept
systemas aSystemSegment[]with per-segmentcache_control. The planner now builds 4 cache breakpoints, ordered most-stable to most-volatile:Schema-correction retry and no-scenes retry now append to the user message instead of the system, so the cached prefix stays valid and retries hit cache too.
Net effect: re-plans / retries / hook-critic calls inside the 5-minute cache TTL pay ~10% of input cost on the cached prefix. Iterative work goes from ~$0.15/video to ~$0.03/video after the first plan.
2. Multi-theme awareness — mix concepts without bloat
Studio API passes a CONDENSED list of every other installed theme to the planner: id + 1-line description + their preference arrays only (~50 tokens per theme). Stays inside the active-theme cache breakpoint so adding a new theme doesn't invalidate the cache for projects that don't use it.
The planner gets a new "Other themes available for cross-pollination" section in its system prompt explaining the two ways to borrow concepts.
3. Per-scene theme override
Planner tool schema gains
scene.themeOverride(validated againstavailableThemes+ the active theme). Materializer threads it through asscene.props.theme. The assembler's render loop honours it: when set, that one scene gets the named theme's tokens (palette + fonts) for its template render + atmosphere injection. Other scenes keep the active theme.Use case: a Dreamspace hook in a HackerNoon-themed video. One prop, no global config change. The planner can also borrow individual atmospheres / transitions from a peer theme without switching the whole palette.
Documentation
docs/design-systems/README.mdgets three new sections:DESIGN_SYSTEM.mdis the spec the planner reads, HTML+GSAP is production. Per-theme template overrides are coming in a follow-up PR.Test plan
GET /api/themes?project=my-first-videoreturns 3 themes; payload size unchangedusagefield forcache_creation_input_tokens(first call) andcache_read_input_tokens(subsequent calls). Hook critic should hit cache too.What's deferred
Theme-shipped templates (per-theme template overrides via
<theme>/templates/<id>.htmlwith{{prop}}substitution + GSAP) is a meaningful new subsystem — design + implementation + tests warrant a focused PR. For now, themes restyle existing templates via tokens + preferences. The planner can already mix per-scene themes for a different aesthetic; templates-per-theme adds the ability to ship pixel-exact custom layouts (T2 prompt-to-app, T5 manifesto, etc.).How the AI uses this
When the user re-plans with the sample script:
scene.themeOverrideon any scene to switch palette + fonts for that scene.