Write a video's world down as a Blender program, then answer questions from the program alone. It helps when the job is geometry: imagined viewpoints gain up to 21.9 points. It hurts when small errors stack: one swapped pair in an order question puts code 21.8 points behind the raw video.
Pick a question type, then make the reconstructed scene more wrong. Watch which input wins: the program (blue) or the raw video (orange). Then we build, piece by piece, the state, the agents that write and read it, and the map of where code helps.
You need a picture of a 3D scene and a camera and a little Python. We build the rest from zero.
The question type (one per read family)
Pick a question type, then drag the scene error to the right.
Accuracies are the paper's (Fig. 7 right): Gemini 3.8 Flash on VSI-Bench-Debiased, code input against video input, grouped by the error that each codified scene happened to have. The groups hold different questions; they are not controlled perturbations of one input, as the paper warns. The room and the drawn errors are illustrative.
Chapter 0
Walk a camera through a room and count the cups two ways
You film a walk through a living room. Then someone asks: how many cups are in the room? No single frame shows all six. Some cups leave the view and come back, seen from a new side.
A frame is one observation. The world state is what persists behind the frames: which objects exist, where they are, and how they and the camera move. Counting the cups needs the state, because each cup must keep one identity while it is out of view.
Today's video models keep that state implicit. A video-language model (VLM) reads the frames and predicts a count or a direction straight from visual features. A video diffusion model generates frames, with identity, geometry and viewpoint tangled inside its latents. Neither keeps a list of objects you can check.
The yellow cone is the camera's view as it walks. Each time a cup enters the cone, a 2D tracker starts a track. Press Walk, or drag the time, and compare the two counts.
Illustrative room, path and 70° view cone; no occlusion. The failure it shows is the paper's: a walkthrough revisits objects and 2D tracks break, so counting tracks overcounts; VideoCoS lifts tracks to 3D and merges revisits of one place (Sec. A.1).
Count the naive way and you get too many cups. The paper meets this problem when it builds rooms: "counting tracks would overcount objects". So it lifts each track into 3D and merges the tracks that land in one place. A room walkthrough runs up to 7.2 minutes at 10 frames per second: 7.2 × 60 × 10 = 4,320 frames, and one list of objects behind them.
VideoCoS (Video Reasoning and Generation via Code States), from UNC Chapel Hill, writes that list down as an executable Blender program. It does not ask "can code do this?". It asks when the program helps video reasoning and generation, and when it hurts, across seven task families.
The failure
Chapter 1
Edit one part of a scene program and watch the other parts hold still
Every frame is a 2D picture of one underlying scene, seen from one viewpoint. VideoCoS splits the scene at frame t into three parts, and claims the three together are enough to render the video again.
Call the set of objects E, their poses at frame t gt, and the camera at frame t ct.
s-t equals the triple E, g-t, c-t; and V equals R of s from one to T.
At each frame, list the objects E, where each one is (g-t) and where the camera is (c-t). Hand the whole sequence s from one to T to the renderer R, and you get the video V back.
A 60-frame Kubric-4D clip with 8 objects (made-up count) has one E of 8 entries, 60 copies of g-t with 8 poses each, and 60 camera poses. To orbit the camera you replace the 60 values of c-t. E and all 480 object poses stay as they were.
The state is not a static annotation. It is a Python program P, scene.py, whose execution builds a live Blender scene, scene.blend, at any frame. That gives three properties the latents of VLMs and diffusion models do not expose:
The program builds the room in the render. Press an edit and watch which lines of the program change. Then switch to an entangled latent and press the same edit.
The program is a short sketch in the style of the paper's scene.py (Fig. 3 shows calls such as box_mesh and arrange_room); the real one is written by the codification agent against a helper library. The latent mode is a cartoon of the paper's claim that diffusion models "frequently corrupt untargeted objects" (Sec. 1), not a model.
The failure
Chapter 2
Sort seven video tasks by which parts of the state they read or change
Once the world is a state, two kinds of task fall out. Answering a question about the video reads the state and leaves it alone. Making a new video changes some part of the state, holds the rest, and renders.
Call a question q and its answer y. Call the conditioning for an edit u: a target camera, a goal, or a request to run time forward.
O-read of s from one to T and q gives y; O-write of s from one to T and u gives s-prime from one to T-prime.
A read takes the states s and a question q and returns an answer y. A write takes the states s and a condition u and returns new states s-prime, which the renderer turns into a video.
Future prediction in Physics-IQ: the observed clip is 3 s, so T covers 3 s. The write must end 5 s after the last observed frame, so T-prime covers 3 + 5 = 8 s. The poses of the first 3 s must not change (Table 8).
The paper sorts public benchmarks into seven task families, each probing specific parts of the state. Pick one and see what it touches.
The three lanes are E, g and c. A read lights the parts it queries. A write draws a new version of the part it changes. Pick a family.
Families, state operations, examples and sample counts are the paper's (Table 1, Fig. 2, Sec. B). Read tasks come from VSI-Bench-Debiased (2,362 questions over 274 room walkthroughs); writes from Kubric-4D, Ego2Act and Physics-IQ.
Read tasks use the official VSI-Bench scoring: numbers earn partial credit by mean relative accuracy (MRA), and options need an exact match. Each write task has one video-level score and one state-level score, such as PSNR and object mask IoU for novel views.
There is one catch. No benchmark comes with a ground-truth program. The codifier must infer every state from raw video, so the study tests whether a noisy reconstruction still helps.
The failure
Chapter 3
Step a coding agent through its repair loop, then take its measurements away
Someone has to write the program. Earlier code-based reconstruction let a coding agent guess 3D structure from appearance alone. The paper says this often gives wrong room sizes, object scales and positions. Then a failed answer could come from the idea or from a bad scene, and you cannot tell which.
So VideoCoS first runs off-the-shelf perception models once per video. Depth Anything 3 gives metric depth, intrinsics and a camera pose per frame. Qwen3.8-27B names objects on 32 frames, and SAM 3 segments and tracks each named object. For rooms, the system lifts tracks to 3D boxes and merges them. Objects at least 0.25 m across get a mesh from SAM 3D Objects. This evidence is read-only.
The codification agent, Codex CLI with GPT-6.1 Terra, writes scene.py against this evidence in a sandboxed Blender 4.5 with no network. It repeats one loop:
A side view of the scene program (blue) over the true scene (teal). Each step builds, checks or fixes. Then switch the evidence off and run it again.
The thresholds are the paper's (Sec. A.2): interpenetration over 8 mm, floating over 1 cm, silhouette IoU under 0.5 against the SAM 3 mask, and a room fails if more than 5% of its objects float. The scene and its flaws are illustrative.
A revision passes if, among other rules, the program runs, every ID is unique, every object has a rigid body, and the file is self-contained. The repair list names each flaw with its size: "cup_3 sinks 2.0 cm into table" reads like a ticket. A room run gets 30 minutes and 16 builds; the median room takes 24 minutes.
| Evidence the agent gets | Centre error | 3D IoU | Interpenetrations | Minutes |
|---|---|---|---|---|
| Frames and cameras | 0.36 m | 0.23 | 10 | 4.2 |
| Fused objects (3D boxes) | 0.40 m | 0.32 | 46 | 4.2 |
| Unfused layers | 0.44 m | 0.23 | 5 | 4.8 |
| Unfused + contact query, mask overlays | 0.29 m | 0.33 | 1 | 7.0 |
That is Table 13, a pilot on ten write samples with one run each. Depth only covers surfaces that face the camera, so fused boxes come out truncated and overlapping: 46 interpenetrations. A contact query, which casts rays through the bottom of an object's mask onto its support, fixes each object's footing without depth. The authors warn that geometry gaps below about 0.06 m are noise.
The failure
Chapter 4
Follow a blind agent's tool calls, then price a scene that answers many questions
The second agent is a language model with function calling and no image input. It gets the question, a JSON summary of the scene and a set of tools. It never sees a frame or a render. So every answer depends only on the codified state: if it is right, the state carried the fact.
For reads it has five tools, and they return text:
Writes add run_python, which edits the live scene and returns a diff, plus track_motion and reset_scene.
Pick a question and press Ask. Each line is one tool call and its text result; the room lights what the tool touched. Then open Many questions.
Tool names and budgets are the paper's (Table 7, Sec. A.3: 6 model turns, 18 tool calls, no code for reads). The room, the replies and the left-right geometry are an illustrative sketch; the paper does not publish the tools' internals. Costs are Table 15's measured averages; the lines are the paper's linear projection (Sec. E.2).
Read tasks get 6 model turns and 18 tool calls. All three reasoners (Qwen3.8-27B, GPT-5.6 Luna, Gemini 3.8 Flash) share the tools, the prompt and the budget, and an unanswered question scores zero. The prompt insists: "use returned measurements rather than inventing them".
The scene does not depend on the question, so VideoCoS builds it once and shares it with every question and every reasoner. That changes the bill. Call the number of questions asked of one scene N.
C-ours of N equals one point five two, plus zero point zero three three times N.
Pay 1.52 once to build the scene. Then pay 0.033 for each of the N questions. SpatialClaw, a video agent that starts over for every question, pays 0.180 times N.
The lines cross where 1.52 + 0.033 N = 0.180 N, so N = 1.52 ÷ 0.147 = 10.34. From the 11th question, the shared scene is cheaper. At N = 18 it costs $2.11 against $3.24, or 65.2%.
The failure
Chapter 5
Orbit the camera up to 128° and see which renders keep the scene
Finding 1 of the paper: executable states help when a task is a direct geometric operation on 3D structure. Changing the viewpoint is the clearest case, both when you read and when you write.
Reads. "If I stand by the TV and face the sofa, is the stool on my left?" A video reasoner must imagine that viewpoint from frames taken somewhere else. In the code state, objects and observers share one 3D frame, so the question becomes a transform. Viewpoint accuracy rises for all three reasoners: GPT-5.6 Luna from 40.6 to 62.5 (+21.9), Gemini from 63.2 to 80.7 (+17.5), Qwen from 59.0 to 60.2.
Relative direction, one of the two viewpoint question types, improves for every reasoner by 14.8 to 32.8 points. It also improves with every scene from BVB, the prior codifier. So the gain comes from putting everything in one frame, not from one particular reconstruction.
Writes. Novel-view synthesis on Kubric-4D gives a method a source video and a target camera, and asks for the same 60 frames from the target. The total view change is 42°, 97° or 128°. A camera write replaces only c and renders the same scene again.
Three renders of one tabletop from the new camera. Drag the view change and compare the code render (blue) and a diffusion-style render (purple) with the true view (teal). The bars are the paper's.
Mask IoU and PSNR are Table 3's (best diffusion baseline per angle). The tabletop and all three renders are illustrative: the code render carries a fixed small reconstruction error and flat materials, as the paper describes; the diffusion render is a cartoon of drift that grows with the angle, not a model.
VideoCoS leads on both metrics at every angle, and its object mask IoU stays at 0.254, 0.230 and 0.224. No diffusion baseline exceeds 0.02, and at 97° and 128° they reach at most 0.004. The ground-truth video itself scores about 0.61, so the code render reaches about 40% of that ceiling: 0.254 ÷ 0.604 = 0.42.
The code numbers are nearly flat because a camera write leaves the scene untouched. A larger angle is not a harder edit. PSNR stays low for everyone (12.67 to 12.98 dB for VideoCoS): the renders reproduce the layout, not the materials or the lighting.
The failure
Chapter 6
Plot the tested video generators by task success and physical realism, then add the hybrid
Two write tasks move objects. Goal-conditioned planning (Ego2Act, 110 cases) starts from one photo and a goal in text, such as "the tape is inside the tape dispenser". It asks for a video of about 15 s. Future prediction (Physics-IQ, 66 scenarios) shows 3 s of a physical event and asks for the next 5 s.
For planning, the agent keyframes each object along a collision-free path to its goal. For prediction, it releases bodies, sets their mass and friction, and bakes a rigid-body simulation. Ego2Act's judge gives each video a task score T (did the goal happen) and a physical score P (does it look physically right). Both run from 0 to 100.
Final equals the mean over videos of the square root of T times P.
For each video, multiply T by P and take the square root. A video scores well only if both T and P are high. Then average over all videos.
The Blender plan's totals are T = 68.2 and P = 50.0. The root of their product is √3,410 = 58.4, but the reported Final is 52.5 (Table 4). The gap is real: averaging per video never exceeds the root of the averages, and it drops further when T and P disagree video by video.
Each dot is a method. Up-and-right is better. Tap a dot to read it. Switch to future prediction, and follow the arrow from MiniMax-H3 to the hybrid.
All points are the paper's: Ego2Act totals over 110 cases (Table 4) and Physics-IQ scores (Table 5). The hybrid uses the Blender video as a reference and re-renders it with MiniMax-H3, with one hand added (Sec. A.5).
Control helps. On planning the Blender plan has the second-highest task score after Seedance-2.0, on short tasks (81.3) and long ones (64.2). On rigid motion in Physics-IQ its trajectory error is 11.1, near Cosmos3 (10.3 and 10.5) and well below MiniMax-H3 (16.9).
Realism hurts. Its physical score is the lowest of all, 50.0: the state has no hand, so objects move on their own. On non-rigid events its trajectory error is the highest (9.9 against 5.3 to 8.0), since rigid-body simulation cannot do fluids or magnets. The hybrid trades. Blender plus MiniMax-H3 lifts H3's task score from 54.3 to 63.5 and its Physics-IQ score from 38.6 to 51.9. But it lowers H3's physical score from 79.2 to 69.4.
The failure
Chapter 7
Order more objects by noisy first sightings and watch the answer fall apart
Finding 2 has a second half: executable states fall short when an answer combines several noisy estimates. The clearest case is appearance order: "Which appears first in the video, the cart, the sofa or the TV?" History accuracy drops for every reasoner, by 12.5 points for Qwen and 13.2 for Gemini.
Why? To answer, the state must say when each object first becomes visible. Each of those times comes from two estimates: the object's position and the camera's path. An order of four objects needs four such times, and one bad time can swap a pair. The whole answer is wrong if any pair is wrong.
Teal ticks are when each object truly first appears. Blue dots are the state's estimates. A red link marks a swapped pair. Add objects or noise, then draw again.
The timeline and its noise are a toy: true sightings one gap apart, each estimate off by Gaussian noise; the curve is 4,000 simulated draws. The two big points per input are the paper's (Fig. 7 top left): at k = 4 they are the History scores 64.5 and 77.7; at k = 2 we add back the stated drops of 20.1 and 13.5 points.
The paper scores the sub-orders of k objects inside each Gemini answer. From k = 2 to k = 4, code accuracy falls 20.1 points and video accuracy 13.5. So the gap to video widens from −6.6 points to −13.2. The error ratio stays steady: (100 − 84.6) ÷ (100 − 91.2) = 1.75 at k = 2 and (100 − 64.5) ÷ (100 − 77.7) = 1.59 at k = 4.
So each code estimate is about 1.6 to 1.75 times as error-prone as the video model's, and more objects multiply the chances to fail. Raw video keeps a direct sense of "what came first" that the reconstructed camera path loses.
The failure
Chapter 8
Find which scene metric predicts a right answer, and which does not
Finding 3 asks what makes a state useful. Three results answer it.
A state beats raw perception. Give Gemini the same perception outputs as raw JSON (per-frame depth, poses and masks) and it scores 56.3, below video at 63.1. The code state scores 65.5. A model cannot fuse fragments by reading them; the scene and its tools organise the evidence.
Task-relevant accuracy tracks answers. The authors codified each room three ways (VideoCoS, and BVB with two models). Across those three, the paper correlates scene metrics with QA accuracy. A question tracks the accuracy of the attribute it asks about, with Spearman ρ from 0.26 to 0.56. It does not track how much the renders look like the video: +0.07 for latent similarity and −0.03 for Dual VQA.
Rows are scene metrics, columns are question types. Blue means more accurate scenes give more right answers. Tap a cell. Then switch to Three inputs.
All values are the paper's (Fig. 7): Spearman correlations across the three reconstructions of each of the 274 rooms, and Gemini 3.8 Flash accuracy with video, raw perception or the code state. Boxed cells pair a state attribute with its own question.
Tolerance differs by task. No reconstruction is exact, so how wrong can it be before video is the better input? This is the hero at the top of the page. For sizes and distances, code wins by 28.8 points when the scene error is under 10% and by 11.3 at 10 to 25%, then loses. For direction it wins until the angle is off by more than 90°. For counts and orders it wins only when the scene is exactly right: one miscounted object costs 8.1 points against video, one swapped pair 21.8.
The reason is the scoring. A rough direction still picks the right side. A close distance earns partial credit. But one object off is a big error in a small count, and one swapped pair makes the whole order wrong.
The failure
Chapter 9
Read and write a toy scene program across all seven families, and corrupt it
Here is the whole loop of the paper's Fig. 3, on a toy room. The true room is teal. The codified state is blue, and you control how wrong it is. Pick a task: four reads, three writes (future prediction twice, once rigid and once fluid). The reasoner works on the blue state only, and a judge checks its answer against the teal truth.
Choose a task and press Run. The trace shows the tool calls on the blue state. Then raise the position error or remove an object, and press Run 50 seeds.
The task
Break the state
A toy, not the paper's system. Each object's codified position is the true one plus Gaussian error; each cup is seen twice, and the two sightings merge only if they land within 30 cm (the 3D merge of Sec. A.1). Orbit scores the mean box overlap of the seven large objects with the true view. Distance answers earn partial credit in 5% steps, the form of VSI-Bench's mean relative accuracy. The fluid task fails by design: the paper's state is rigid-body only (Sec. E.3).
Things to try. Leave the error at 8 cm and run all tasks: almost everything passes.
Raise it to 30 cm. Left or right still passes nearly every seed, and distance keeps most of its partial credit. Counts fall to about one seed in ten and orders to about six in ten, because one merge error or one swapped pair makes the answer wrong.
Remove the stool and both questions about it fail outright, the "object absent" rows of the hero. Pour water at any error and the write fails: the state has no fluid in it.
The toy reproduces the paper's shape, not its numbers. Geometry tolerates an approximate state; counts and orders do not; physics outside rigid bodies is not in the state at all. Reading and writing share one scene, so the scene that answers your questions is the one you edit for novel views, plans and predictions.
The failure
Chapter 10
Keep the map, the numbers, the core as code, the limits and where to go next
VideoCoS turns a video into a Blender program with perception evidence and a build, check and fix loop. A separate agent that never sees the video reads the program to answer questions and edits it to make new videos. It helps on geometry (viewpoints, novel views, rigid plans). It falls short on answers that compound noisy estimates and on physical realism. What decides a read is the accuracy of the fact it needs, not how the scene looks.
| Result | Code state | Against | Source |
|---|---|---|---|
| Viewpoint reads | 80.7 Gemini, 62.5 GPT | 63.2 and 40.6 on video (+17.5, +21.9) | Table 2 |
| History (order) reads | 64.5 Gemini | 77.7 on video (−13.2) | Table 2 |
| All reads, Gemini | 65.5 | 63.1 video, 56.3 raw perception | Fig. 7 |
| Novel-view mask IoU, 42° / 97° / 128° | 0.254 / 0.230 / 0.224 | at most 0.020 for diffusion; 0.60 to 0.62 ceiling | Table 3 |
| Goal planning, task / physical | 68.2 / 50.0 | 77.3 / 88.9 Seedance-2.0; hybrid 63.5 / 69.4 | Table 4 |
| Physics-IQ, rigid ADE / non-rigid ADE | 11.1 / 9.9 | 10.3 / 5.4 Cosmos3-Super | Table 5 |
| Error tolerance, size and distance | +28.8 under 10% error | loses beyond 25% | Fig. 7 |
| Error tolerance, count and order | −8.1 one off, −21.8 one pair | wins only when exact | Fig. 7 |
| API cost | $1.52 build + $0.033 per question | $0.180 SpatialClaw; cheaper from question 11 | Sec. E.2 |
python import numpy as np # A toy world state: E (identities), g (positions per frame), c (camera per frame). def measure_pair(scene, a, b, t=0): return float(np.linalg.norm(scene.g[t][a] - scene.g[t][b])) # box centres, metres def viewpoint_relation(scene, observer, facing, subject, t=0): o, f, s = (scene.g[t][k][:2] for k in (observer, facing, subject)) fwd, rel = f - o, s - o cross = fwd[0] * rel[1] - fwd[1] * rel[0] # z up: positive means left return "left" if cross > 0 else "right" def first_visible(scene, obj, fov_deg=70): for t, (pos, yaw) in enumerate(scene.c): # the camera path d = scene.g[t][obj][:2] - pos[:2] ang = np.degrees(np.arctan2(d[1], d[0]) - yaw) if abs((ang + 180) % 360 - 180) < fov_deg / 2: return t return None # absent or unseen def orbit_camera(scene, new_path): scene.c = new_path # a write: E and g untouched return scene def cumulative_cost(n, build=1.52, per_q=0.033): return build + per_q * n # cheaper than 0.180 n from n = 11
Based on "VideoCoS: When Do Executable World States Help Video Reasoning and Generation?" by Shoubin Yu, Daeun Lee, Zun Wang, Han Lin, Yue Zhang and Mohit Bansal (UNC Chapel Hill, 2026), arXiv:2611.35375. Every number on this page is from the paper; the toys and their limits are labelled where they appear.
Now press Present or Teach and explain from memory: the state, reads and writes, the repair loop, the blind reasoner, where code wins, where it falls short, and why accuracy beats looks. Then go back to the hero, pick Order, and say why one swapped pair costs 21.8 points.