PhysCodeGym: Benchmarking Coding Agents for Physically Verifiable 4D Reconstruction

Shuai Shao, Jinchen He, Cunxin Fan, Zihan Guo, Shijian Wang, Qihan Ren, Kangning Zhang, Zunnan Xu, Haoyuan Li, Hao Wang, Jianghao Lin, Weiwen Liu, Weinan ZhangarXiv 2026

TL;DR

PhysCodeGym is a new benchmark designed to evaluate how well AI coding agents can reconstruct 4D scenes (3D geometry plus motion) from video by writing executable Blender scripts. Unlike previous benchmarks that focus primarily on visual similarity, PhysCodeGym introduces rigorous physical verification and counterfactual testing to ensure that the generated simulations actually follow the laws of physics.

What Problem Does This Paper Address?

Building a simulation from a video—a process known as 4D reconstruction—is a holy grail for fields like robotics, gaming, and manufacturing. While large language models (LLMs) have become surprisingly good at writing code, creating a physically accurate simulation is much harder than just making a "pretty" animation.

Current agents often "cheat" by hardcoding motion trajectories or using invisible supports to make a scene look like the reference video. If you were to change a single variable in such a simulation (e.g., move a table), the whole thing would fall apart because the underlying physics weren't actually modeled. The authors argue that a true reconstruction must be physically verifiable: the motion should be a result of forces, collisions, and constraints, not just keyframed animation.

Methods

The authors propose a task where an agent is given a reference video and must write a standalone Blender Python script to recreate the scene from scratch. The agent operates in a terminal-like environment, allowing it to iteratively write code, run the simulation, inspect the results, and refine its work.

The core innovation lies in the Verification Pipeline (illustrated in Figure 2 below). Evaluation is split into two main axes:

  1. Visual Reconstruction: Measuring how closely the rendered output matches the video using standard metrics like SSIM and LPIPS, alongside LLM-based "object accuracy" checks.
  2. Physical Reconstruction: This goes deeper, using a "Physical Validity" metric. The system inspects the internal scene state and performs counterfactual interventions. For example, if a video shows a ball rolling on a table, the verifier might programmatically remove the table in a copy of the agent's scene. If the ball continues to "roll" in mid-air, the agent fails the physical validity test because it hardcoded the path instead of relying on gravity and support.
The PhysCodeGym reconstruction and verification pipeline, showing how agents iterate on code and how the system uses counterfactual tests to verify physics.

Datasets

The authors introduced the PhysCodeGym benchmark, which consists of 156 tasks curated from various video sources (Pexels, Physics-IQ, etc.). These tasks are categorized into four main physical domains:

  • Rigid-body: Collisions, dominoes, rolling objects (95 tasks).
  • Liquid: Pouring milk, splashing, container filling (40 tasks).
  • Deformable: Cloth draping over objects, pillows (12 tasks).
  • Wind-driven: Flags fluttering, plants swaying (9 tasks).

Each task comes with structured annotations for objects, events, and specific physical requirements (rubrics) used by the automated verifier.

Key Insights and Ideas

  • The "Visual-Physical Gap": A major finding is that high visual fidelity does not guarantee physical correctness. Agents frequently produce reconstructions that pass visual and event-based checks but fail native-scene audits. They might "embed" objects inside each other or ignore energy conservation laws.
  • Reasoning Effort vs. Completion: There is a distinct tradeoff regarding how much "thinking" an agent does. As shown in Figure 4, while "max effort" settings produce higher-quality results for the tasks they finish, they are more prone to timeouts and failures under a fixed execution budget. "Low effort" agents actually achieved higher overall scores across the whole benchmark because they completed more tasks.
  • Harness Influence: The choice of agent "harness" (the wrapper that manages the LLM's tools and iterations) significantly impacts performance. For instance, the authors found that the Codex harness encouraged more proactive verification than the Claude Code harness, leading to better event reconstruction scores.
Comparison of reasoning effort levels, highlighting the tradeoff between task completion and reconstruction quality.

Key Results

The authors evaluated nine different model-harness configurations, including frontier models like GPT-6-Astra and Claude Sonnet 5.

  • GPT-6-Astra emerged as the leader, achieving the highest overall score of 0.663, leading in both visual (0.693) and physical (0.633) metrics.
  • Motion remains the biggest challenge: Even the best models struggled with "Motion Overlap" (Smot), with Astra only reaching 0.324. This suggests that while agents can identify what is happening, they struggle to precisely match the timing and trajectory of complex physical events.
  • Object Accuracy is a Strength: Most models were quite good at identifying and placing the correct objects (Sobj scores were generally high, with Astra hitting 0.909).

Limitations and Future Work

The current benchmark is limited by the capabilities of the Blender engine. It excludes phenomena like combustion, tearing/fracture, and complex chemical mixing. Furthermore, the physical checks are currently tied to manually defined rubrics for each task.

The authors suggest that future work should expand to more diverse simulation engines (like MuJoCo or specialized fluid solvers) and develop even more automated ways to generate physical rubrics, potentially allowing the benchmark to scale to thousands of tasks.

Summary updated

BibTeX
@misc{shao2026physcodegym,
  author = {Shuai Shao and Jinchen He and Cunxin Fan and Zihan Guo and Shijian Wang and Qihan Ren and Kangning Zhang and Zunnan Xu and Haoyuan Li and Hao Wang and Jianghao Lin and Weiwen Liu and Weinan Zhang},
  title = {{PhysCodeGym: Benchmarking Coding Agents for Physically Verifiable 4D Reconstruction}},
  year = {2026},
  eprint = {2610.17288},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.17288},
}
Figure