PhysCodeGym: Benchmarking Coding Agents for Physically Verifiable 4D Reconstruction
Organizations: Shanghai Jiao Tong University · Sun Yat-sen University · Shanghai Innovation Institute · Southeast University ·
Abstract
Building physical simulations from video requires coding agents to translate observations into executable models and refine them through tool use. We introduce PhysCodeGym, a benchmark for physically verifiable 4D reconstruction with tasks covering rigid-body, liquid, deformable, and wind-driven motion. Agents autonomously inspect videos, write and run Blender programs, and revise their scenes using simulation feedback. Six metrics combine rule-based measurements with rubric-based judgments to assess visual and physical reconstruction quality. Program inspection, scene measurements, and counterfactual interventions test physical consistency under original and modified conditions. Experiments with frontier coding agents reveal a tradeoff between artifact quality and completion across reasoning-effort settings, while harness comparisons and agent traces link verification behavior with reconstruction performance. Case studies show that matching visible objects and events can coexist with physical defects. Counterfactual tests further expose latent contact and support failures in reconstructions that pass ordinary physical checks, highlighting the gap between reproducing observations and building reliable physical models. Code is available at https://github.com/ShaoShuai0605/PhysCodeGym.
Figures & tables
| Benchmark | Task | Input | Visual Eval. | Behavioral Fidelity | Physical Implementation | Harness | ||
| Event Eval. | Motion Alignment | Internal Physics Checks | Mechanism Dependence | |||||
| Code4D [ 66 ] | Gen. | Text | ✓ | ✗ | ✗ | ✗ | ✗ | Multi-agent code loop |
| 4DBuildBench [ 32 ] | Gen. | Text | ✓ | ✓ | ✗ | ✓ | ✗ | Multi-agent MCP |
| PhysCodeBench [ 56 ] | Gen. | Text | ✓ | ✓ | ✗ | ✓ | ✗ | Direct codegen. / SMRF |
| SceneActBench [ 68 ] | Recon. | Syn. frames | ✓ | ✗ | ✓ | ✗ | ✗ | Shared MCP |
| VisPhyBench [ 31 ] | Recon. | Syn. frames | ✓ | ✗ | ✓ | ✓ | ✗ | Codegen. + repair |
| Harness | Model | Visual | Physical | |||||||
| Codex | GPT-6-Astra | 0.610 | 0.561 | 0.909 | 0.693 | 0.805 | 0.324 | 0.768 | 0.633 | 0.663 |
| GPT-5.6-Sol | 0.550 | 0.448 | 0.835 | 0.611 | 0.687 | 0.210 | 0.690 | 0.529 | 0.570 | |
| GPT-6-Luna | 0.518 | 0.363 | 0.633 | 0.505 | 0.393 | 0.128 | 0.555 | 0.359 | 0.432 | |
| GPT-5.6-Luna | 0.506 | 0.355 | 0.639 | 0.500 | 0.448 | 0.157 | 0.564 | 0.391 | 0.446 | |
| Claude Code | DeepSeek-V4.1-Flash | 0.514 | 0.398 | 0.615 | 0.509 | 0.446 | 0.200 | 0.522 | 0.391 | 0.450 |
Appendix figures & tables31 assets
Supplementary material from the paper’s appendix.
Appendix
| Category | Subcategory | Tasks | Event items |
| Rigid body | Falling and bouncing | 16 | 71 |
| Rolling and tracks | 18 | 68 | |
| Collision and chain reactions | 14 | 56 | |
| Swinging and suspension | 16 | 51 | |
| Rotation | 20 | 63 | |
| Granular and multi-object piling | 7 | 22 |
| Source | Rigid body | Liquid | Deformable | Wind-driven | Total |
| Pexels | 69 | 35 | 9 | 9 | 122 |
| Physics-IQ | 19 | 5 | 3 | 0 | 27 |
| BAAI-DataCube Physics-aware Videos | 5 | 0 | 0 | 0 | 5 |
| IRIS | 2 | 0 | 0 | 0 | 2 |
| Total | 95 | 40 | 12 | 9 | 156 |
| Model | Harness | ||||||
| GPT-6-Astra | Codex | 0.694 | 0.806 | 0.325 | 0.768 | 0.633 | 0.664 |
| GPT-5.6-Sol | Codex | 0.611 | 0.687 | 0.210 | 0.690 | 0.529 | 0.570 |
| GPT-6-Luna | Codex | 0.507 | 0.392 | 0.129 | 0.555 | 0.359 | 0.433 |
| GPT-5.6-Luna | Codex | 0.503 | 0.450 | 0.157 | 0.564 | 0.391 | 0.447 |
| DeepSeek-V4.1-Flash | Claude Code | 0.511 | 0.452 | 0.200 | 0.522 | 0.391 | 0.451 |
| Claude Sonnet 5 | Claude Code | 0.436 | 0.370 | 0.111 | 0.559 | 0.347 | 0.392 |
| Harness | Model | Visual | Physical | |||||||
| Codex | GPT-6-Astra | 0.610 | 0.561 | 0.909 | 0.693 | 0.805 | 0.324 | 0.768 | 0.633 | 0.663 |
| GPT-5.6-Sol | 0.553 | 0.451 | 0.840 | 0.615 | 0.692 | 0.211 | 0.694 | 0.532 | 0.574 | |
| GPT-6-Luna | 0.554 | 0.387 | 0.677 | 0.539 | 0.420 | 0.136 | 0.593 | 0.384 | 0.462 | |
| GPT-5.6-Luna | 0.529 | 0.371 | 0.669 | 0.523 | 0.469 | 0.165 | 0.591 | 0.409 | 0.466 | |
| Claude Code | DeepSeek-V4.1-Flash | 0.599 | 0.463 | 0.716 | 0.593 | 0.520 | 0.233 | 0.609 | 0.456 | 0.525 |
| Averaging set | Low | High | Max |
| Benchmark aggregate | 0.476 | 0.450 | 0.460 |
| Each setting’s produced artifacts | 0.527 | 0.525 | 0.547 |
| Shared tasks with outputs and physical judgments | 0.533 | 0.535 | 0.564 |
| Question | Cases | Main observation |
| What differs when one metric is high? | Two pendulums; rolling quail egg | High motion overlap can coexist with incomplete events or physical violations. |
| What differs when one metric is equal? | Wine pouring; avocado halves | Equal event or validity scores coexist with differences in appearance and event progression. |
| What does scene inspection reveal? | Thai flag | An event score of coexists with cloth self-intersections. |
| Evidence | Claude Code | Codex |
| Benchmark task | Explicitly requires verification and finalization. | Same task body; an additional leading reminder repeats the final-validation budget requirement. |
| Native prompt | Historical full prompt unavailable. Version-matched local captures emphasize faithful reporting of tests and skipped steps. | Historical session metadata records an explicit proactive-testing instruction under never . |
| Interpretation | Earlier checks are present, but the final revisions in these two cases remain unexecuted. | The final revisions in these two cases are run and inspected before the attempt ends. |
| Task | Claude Code | Codex |
| Wooden piece | Revises the final program after the cap is reached; static checks pass, but execution is blocked and output checks fail (166–205). | Detects stalling, revises contact settings, executes the final program at launch 20, then checks frames and finalizes (132–169). |
| Wine pouring | After a bake abort, changes numerical settings without a successful subsequent execution; finalizer reports missing frames (224–248). | Detects excessive accumulation, adjusts the inlet twice, reruns after each edit, inspects final frames, and checks a saved-scene preview (80–94). |