EcoVid: Efficient Code to Video with a Token-Saving and Geometry-Aware Agent Harness

Zexuan Yan, Zhikai Wang, Zhenkun Gao, Yizhuo Jia, Juncheng Zhou, Xinyu Wang, Yuzhou Wu, Jinghong Liu, Yuanhuiyi Lyu, Yue Ma, Linfeng ZhangarXiv 2026

TL;DR

Ask an AI to generate an animated explainer video by writing graphics code, and you get crisp equations and sharp diagrams—until the text collides, the voiceover drifts out of sync, and your API bill hits several dollars for a single minute of footage. The authors discover that coding agents waste 75% of their tokens on tedious "mechanical bookkeeping" rather than creative design. By offloading math, layout inspection, and memory management to a lightweight software harness called EcoVid, they slash token usage by up to 84% while producing clean, tightly synchronized animations.

Representative EcoVid output frame showing Newton's Method with crisp equations and zero layout collisions.

What Problem Does This Paper Address?

Pixel-based video diffusion models can conjure photorealistic waves crashing on a beach, yet they struggle to spell words or keep mathematical diagrams structurally consistent. For educational explainers, code-to-video is a much cleaner paradigm: have an LLM write executable graphics code in frameworks like Manim (popularized by 3Blue1Brown), Remotion (React-based video), or HyperFrames (HTML/SVG).

In practice, however, iterative Vision-Language Model (VLM) agents are surprisingly fragile and expensive at this task. When the authors traced multi-turn agent trajectories, they found three glaring bottlenecks:

  1. Pixel-blind debugging: Agents render video frames and feed screenshots to a vision model to spot overlapping text. Because VLMs are bad at estimating exact pixel coordinates on dense canvases, their proposed fixes rarely resolve collisions—while burning huge amounts of vision tokens.
  2. Audio-visual drift: Agents either align audio only at coarse scene boundaries or manually convert speech timestamps into frame numbers, accumulating arithmetic errors that leave animations lagging behind the narrator or ending in awkward frozen silence.
  3. Broken cache economics: Modern LLM APIs offer steep discounts via prefix KV-caching—reusing computation when the start of a prompt matches the previous turn's prompt byte-for-byte. Naive agents either let repair histories balloon quadratically or prune old turns at every step, constantly mutating the prompt prefix and triggering expensive cache misses.

Methods

Instead of asking an LLM to act as an accountant, a ruler, and an animator all at once, EcoVid wraps the model in a carrier-agnostic, deterministic runtime harness built on three mechanisms:

  • Symbolic TTS Timing Binding: Rather than hardcoding seconds or frame indices, the LLM tags each narration sentence with a symbolic anchor (e.g., [[s1]]) and schedules animations using normalized progress from 0 to 1 within that symbol. After Text-to-Speech (TTS) audio is generated, the harness measures exact acoustic intervals and binds them to the symbols at runtime, eliminating cumulative timing drift.
  • Geometry-Aware Feedback (GAF): Before rendering a single video pixel, the harness queries the graphics engine's underlying scene graph at 8 Hz across the timeline. It deterministically extracts exact bounding boxes, z-index stacking, contrast, and font sizes to flag overlaps or off-canvas clipping in ~2.1 seconds. These spatial bugs are fed back to the LLM as compact text diagnostics for batched code repair at zero vision-token cost. Only once the geometry is 100% clean does the harness render a single 9-frame contact sheet for one optional holistic aesthetic check.
  • Cache-Aware Context Management: Instead of summarizing conversation history on every turn (which destroys the prompt prefix), EcoVid compacts superseded code drafts only at discrete epoch boundaries—specifically every $s=4$ turns, while keeping the last $w=2$ turns verbatim. Within each 4-turn window, the leading prefix stays byte-identical, maximizing KV-cache hits while keeping total context bounded.
EcoVid output frame illustrating the Refrigeration Cycle with structured layout and clear typography.

Datasets

This is an inference-time agent architecture rather than a trained model, so no training datasets are used. For evaluation, the authors introduce Bench60, a new 60-topic bilingual benchmark covering instructional prompts across science, everyday life, astronomy, geography, health, and sports rules. Unlike prior single-engine benchmarks, Bench60 evaluates systems across three distinct rendering carriers: Remotion, HyperFrames, and Manim.

Key Insights and Ideas

  • 75% of agent effort is bookkeeping: Tracing native VLM agents revealed that 75.0% of tokens and 75.4% of model calls go toward screenshot debugging, CLI probing, and frame math—leaving just 18.5% of tokens for actually writing animation code.
  • Context pruning has a U-shaped cost curve: Never compacting history bloats total token count, whereas compacting on every turn ("sliding window") spikes the cache-miss rate and raises API bills. Periodic epoch compaction hits the sweet spot between short prompts and high cache reuse.
  • Better harnesses beat bigger models: Applying EcoVid to mid-tier or open-weight models yields cleaner layouts and better audio sync than running frontier models (like Claude-Opus-5.5 or GPT-5.6) inside standard VLM agent loops.

Key Results

Evaluated on Bench60 using Qwen3.8-Max-Medium across Remotion, HyperFrames, and Manim:

  • Cost & Token Savings: EcoVid cuts token usage by up to 84% (e.g., 1,135K down to 183K on Manim) and official API cost by up to 57% ($0.21–$0.28 per video vs. $0.39–$3.58 for baselines), converging in under 14 LLM calls.
  • Layout Quality: Static-frame layout defects drop from 15.4%–45.9% in baselines down to 5.8% (Remotion), 6.8% (HyperFrames), and 2.8% (Manim)—and as low as 0.2% when paired with Claude-Opus-5.5.
  • Tighter Synchronization: Symbolic binding raises synchronized video duration from 52.0%–68.5% in baselines to 96.1%, shrinking frozen tail frames from >12% down to 1.2%.
EcoVid Manim output demonstrating clean mathematical grids and color mapping for Space-Filling Curves.

Limitations and Future Work

Not discussed in the paper.

Summary updated

BibTeX
@misc{yan2026ecovid,
  author = {Zexuan Yan and Zhikai Wang and Zhenkun Gao and Yizhuo Jia and Juncheng Zhou and Xinyu Wang and Yuzhou Wu and Jinghong Liu and Yuanhuiyi Lyu and Yue Ma and Linfeng Zhang},
  title = {{EcoVid: Efficient Code to Video with a Token-Saving and Geometry-Aware Agent Harness}},
  year = {2026},
  eprint = {2611.40472},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.40472},
}
Figure