Code That Works, Environments That Don't: Measuring Environment Reproducibility in AI-Generated Software
Organizations: Department of Electrical Engineering and Computer Science, University of Missouri–Columbia, Missouri, USA
Abstract
Code generation has emerged as a central capability of large language models, with coding agents now able to produce functionally correct software projects from natural language prompts. However, functional correctness alone does not capture a critical dimension of generation quality: environment specification, defined as the accurate identification of the dependencies required to execute generated code, is equally critical. We develop an agent protocol for environment specification and introduce a three-layer framework comprising declared, runtime-installed, and necessary-and-sufficient dependencies to systematically assess coding agents for environment specification. Using this protocol, we evaluate the extent to which coding agents systematically misspecify software environment dependencies and how this misspecification varies across three agents, four languages, and fifty programming tasks. Our results show that current coding agents exhibit systematic generalization failures along this dimension, producing dependency specifications that are inconsistent, redundant, or incomplete in ways that functional tests do not detect. Across agents, dependency set agreement is as low as 7% for identical tasks, and newer agents show no meaningful improvement, suggesting the failure is not resolved by scale or recency. The largest divergence occurs between the declared and runtime dependency layers, implicating environment priors learned from the models' training distributions as the primary driver. Our findings establish environment specification as a distinct, measurable axis of code generation quality that current benchmarks do not capture, and motivate training objectives and evaluation protocols that jointly optimize for functional correctness and environmental portability.
Figures & tables
| Domain | Representative tasks | |
|---|---|---|
| Data Processing | 10 | CSV statistical analyzer, JSON schema validator, XML-to-JSON converter, YAML config merger |
| Cryptography | 7 | AES-256 file encryption, RSA digital signatures, TOTP generator, bcrypt hasher |
| Image Processing | 6 | Format converter, watermarking, histogram analyzer, EXIF metadata extractor |
| Networking | 6 | HTTP downloader with retry, port scanner, DNS resolver, static file server |
| Text Processing | 6 | Markdown-to-HTML, spell checker, TF-IDF search engine, template engine |
| Compression | 5 | ZIP archive manager, GZIP tool, file deduplicator, compression benchmark |
| Dimension | Count |
|---|---|
| Benchmark programming tasks | 50 |
| Target language ecosystems | 4 |
| LLM coding agents | 3 |
| Primary configurations ( ) | 600 |
| Stochastic trials (Claude Code, 2 extra 200) | 400 |
| Maximum agent interactions per instance | 11 |
| Ecosystem | Layer 1: | Layer 2: | Layer 3: |
|---|---|---|---|
| Python | Parse requirements.txt line by line; strip version constraints | Diff of pip list before vs. after pip install | Syscall READ s under dist-packages/ or site-packages/ |
| Java | <artifactId> values in pom.xml <dependencies> | mvn dependency:list artifact IDs (full transitive closure) | Syscall READ s of target/dependency/*.jar via classpath execution |
| JavaScript | Keys of "dependencies" in package.json | npm list --all --json ; full node_modules/ tree | Syscall READ s under node_modules/ |
| C++ | FetchContent_Declare and find_package names in CMakeLists.txt | CMake configure log ( ; transitive expansion typically absent) | Syscall READ s of .so files; seven base system libraries excluded |
| Agent | Language | Precision | Recall | F1 |
|---|---|---|---|---|
| Claude | Python | 0.990 | 0.642 | 0.733 |
| Claude | Java | 0.935 | 0.739 | 0.758 |
| Claude | JavaScript | 0.929 | 0.406 | 0.493 |
| Claude | C++ | 0.037 | 0.781 | 0.031 |
| Codex | Python | 0.938 | 0.827 | 0.837 |
| Codex | Java | 0.939 | 0.684 | 0.735 |
| Language | Mean | Median | UCR | ||
|---|---|---|---|---|---|
| Python | 0.113 | 0.083 | 0/50 (0.0%) | 5.5 | 0.2 |
| Java | 0.138 | 0.111 | 0/48 (0.0%) | 5.6 | 0.1 |
| JavaScript | 0.068 | 0.000 | 0/50 (0.0%) | 5.9 | 0.0 |
| C++ | 0.093 | 0.067 | 0/35 (0.0%) | 5.3 | 0.1 |
| Agent | Fail | SysLib | SLAR | Rec. | EGAR |
|---|---|---|---|---|---|
| Claude | 32 | 28 | 87.5% | 28 | 100.0% |
| Codex | 28 | 5 | 17.9% | 5 | 100.0% |
| Gemini | 10 | 0 | 0.0% | 0 | – |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Ecosystem | -value | |
|---|---|---|
| Python | 0.0006 | |
| Java | 0.0013 | |
| JavaScript | 0.2564 | |
| C++ | 0.0000 |
| ID | Metric | Key quantity | Results |
|---|---|---|---|
| M1 | Success rate under self-correction | , | § 6.1 |
| M2 | Environment growth | § 6.2 | |
| M3 | Phantom / hidden / bloat rates | , , | § 6.2 |
| M4 | Manifest accuracy | P, R, F1 | § 6.2 |
| M5 | Cross-agent consistency | , CDR | § 6.3 |
| M6 | Stochastic variability | , UCR | § 6.3 |
| ID | Problem | Domain | Cx. | ID | Problem | Domain | Cx. |
|---|---|---|---|---|---|---|---|
| p_01 | CSV Statistical Analyzer | Data Processing | M | p_26 | DNS Resolver | Networking | M |
| p_02 | JSON Schema Validator | Data Processing | M | p_27 | HTTP REST Client w/ Retry | Networking | H |
| p_03 | XML to JSON Converter | Data Processing | M | p_28 | Static HTTP File Server | Networking | H |
| p_04 | YAML Config Merger | Data Processing | M | p_29 | Network Latency Monitor | Networking | M |
| p_05 | Log File Pattern Analyzer | Data Processing | M | p_30 | Markdown to HTML Converter | Text Processing | M |
| p_06 | SQLite Database Manager | Data Processing | H | p_31 | Spell Checker | Text Processing | M |
| Ecosystem | Most frequent phantom packages |
|---|---|
| Python | pycparser (6), pandas (5), tabulate (2), tzdata (1), python-dateutil (1) |
| Java | gson (2), zxing-javase (2), zxing-core (2), slf4j-api (1), javalin (1) |
| JavaScript | yargs (46), sharp (8), fast-csv (4), lodash (4), js-yaml (3) |
| C++ | nlohmann_json (65), openssl (16), opencv (11), yaml-cpp (5), mbedtls (5) |
| Ecosystem | Most frequent hidden packages |
|---|---|
| Python | six (31), python-dateutil (23), pytz (20), packaging (14), kiwisolver (11) |
| Java | jackson-annotations (21), jackson-core (20), slf4j-api (14), commons-logging (12), error_prone_annotations (12) |
| JavaScript | ansi-styles (15), supports-color (13), has-flag (13), emoji-regex (9), is-fullwidth-code-point (9) |
| C++ | crypto (16), z (14), zstd (6), nettle (6), krb5 (5) |