Skip to main content

CodeFix-Env

CodeFix-Env v0.2.3: Code Debugging Environment

A sandboxed reinforcement learning environment for training and evaluating LLM agents on automated code debugging, and the fast, verifiable feedback loop that kind of training requires.

CI status PyPI version Apache 2.0 License Tests passing

Quick Start · Architecture · Security · Contributing


Status: active development. The environment, sandbox, reward pipeline, and task registry are stable and tested. A trained-policy result and a larger, mined task set are in progress — see Roadmap.


Table of Contents


Why CodeFix-Env?

Training a coding agent to debug software requires more than static examples of correct code. It requires a tight loop: propose a fix, execute it against a real test suite, and receive a signal that reflects genuine progress rather than superficial activity.

We do that because SWE-bench1 gave coding agents a scalable, realistic evaluation standard, built on full repositories and real GitHub issues. What it does not give is a fast enough loop for on-policy reinforcement learning, where thousands of cheap episodes per training step are typically required.

Most environments used for this today sit at one of two extremes: repository-scale benchmarks that are realistic but slow to sandbox, or ad-hoc code execution with no meaningful isolation at all. CodeFix-Env is built for the space between them.

CodeFix-Env is building that middle layer:

a sandboxed, densely-rewarded reinforcement learning environment for single-function code repair, fast enough to serve as a rollout source, with a stated threat model rather than an assumed one

We do that by:

  • executing every agent action inside a layered sandbox — static AST filtering, restricted builtins, and OS-level process isolation — documented in full in SECURITY.md, including two hardening attempts that failed under load and were reverted rather than left unreported
  • computing a dense, per-step reward from hidden test-pass-rate deltas, rather than a single pass/fail signal at episode end
  • mining task candidates directly from real, merged bug-fix pull requests on GitHub, so tasks can be traced back to an actual historical defect (scripts/mine_tasks.py)
  • publishing the environment as an installable, continuously tested package rather than a static research repository

Our goal is to grow this into a task set and training result large enough to serve as a genuine benchmark and training ground for code-repair agents, in the same way SWE-bench did for repository-scale evaluation.

1 https://arXiv:2607.XXXXX, 2026


Install

pip install codefix-env

For development, or to use the training extras:

git clone https://github.com/dhakarshailendra829/codefix-env.git
cd codefix-env
python -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate
pip install -e ".[dev]"       # add ",llm" for transformers/TRL/accelerate

Verify:

codefix-server info

Quick Start

Local environment — run episodes directly in Python, no server required:

from codefix_env import CodeFixEnvironment, CodeFixAction, ActionType

env = CodeFixEnvironment()
obs = env.reset(task_id="easy-001-missing-return")

result = env.step(CodeFixAction(action_type=ActionType.RUN_TESTS))
print(f"{result.observation.tests_passed}/{result.observation.tests_total} tests passing")

result = env.step(CodeFixAction(
    action_type=ActionType.EDIT_LINE,
    line_number=3,
    new_content="    return result",
))

result = env.step(CodeFixAction(action_type=ActionType.SUBMIT_FIX))
print("solved" if result.observation.all_tests_pass else "not solved", result.reward)

Server mode — expose the environment over HTTP for remote or multi-language clients:

codefix-server serve --port 8000

Task inspection — list and filter the task registry:

codefix-server tasks

Baseline evaluation — run oracle and random policies across the full task set:

python scripts/run_baseline_eval.py --episodes 3

Deployment

The repository includes a Dockerfile for running the environment as a standalone service:

docker build -t codefix-env .
docker run -p 8000:8000 codefix-env

Set CODEFIX_REWARD_MODEL_PATH if using a trained neural reward checkpoint (see ARCHITECTURE.md). No other environment variables are required for the default, rule-based reward configuration.


How It Works

When an episode runs, CodeFix-Env:

  1. Loads a task — a buggy function, a hidden test suite, and graduated hints
  2. Receives a structured action from the agent: run tests, edit a line, insert, delete, request a hint, view the code, or submit
  3. Executes any code-mutating action inside the sandbox, isolated from the host process
  4. Computes a unified diff against the original code and a dense, shaped reward from the test-pass-rate change
  5. Returns the updated observation, including test output and the diff, so the agent can decide its next action
  6. Terminates the episode on a full solve, an explicit submission, or the step budget running out

Full design detail, including the reward formula and the sandbox's layered isolation model, is in ARCHITECTURE.md.


Benchmark

Regenerate these numbers with python scripts/run_baseline_eval.py --episodes 3.

Oracle policy (applies the known-correct fix) versus a random policy, across all 21 tasks:

Policy Easy Medium Hard
Oracle 100% 87.5% 60%
Random 0% 0% 20%

No trained-policy result yet — this compares two fixed baselines to confirm the reward signal discriminates genuine problem-solving from undirected action. A GRPO training result is in progress; see Roadmap.


Capabilities

Sandboxed execution Static AST filtering, restricted builtins, and OS-level process isolation, with a documented threat model
Dense reward shaping Per-step reward from test-pass-rate deltas, hint-usage and step-count penalties, and a solve bonus
Graded task registry 21 tasks across easy, medium, and hard tiers, each with hidden tests and progressive hints
Task mining pipeline Extracts candidate tasks from real, merged GitHub bug-fix pull requests for human review
Server and async client FastAPI HTTP server with a session-scoped API, plus an async client for training loops
Framework-compatible Gymnasium-style reset()/step()/state() interface; usable with SFT, DPO, GRPO, and PPO training code
CI-gated 197 tests, linting, and type checking on every change, across Python 3.10 through 3.12

Roadmap

  • Closed-loop RL training result: fine-tune a small open-weight code model against the environment and publish a measured pass-rate curve
  • A trained checkpoint for the optional learned reward model, calibrated against oracle judgment
  • Task registry expansion from 21 to several hundred tasks, mined and reviewed from real repositories
  • Multi-file task support, extending beyond single-function scope
  • Container-level sandbox isolation (namespace and capability restrictions, seccomp filtering)
  • Support for a second programming language
  • Horizontally scalable session handling for distributed rollout collection
  • Listing on the OpenEnv Hub

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md for local setup, the task-authoring template, and the pull request workflow.


Security

Execution isolation is treated as a first-class design concern, not an afterthought — including reporting what the current sandbox does not protect against. See SECURITY.md for the full threat model and for responsible disclosure of any suspected sandbox escape.


License

Apache License 2.0 — see LICENSE.

Citations

2 Dhakad, S. CodeFix-Env: A Sandboxed Reinforcement Learning Environment for Automated Code Debugging. arXiv:2607.XXXXX, 2026.

Metadata

Release files for codefix-env 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codefix-env 0.2.3
File Size Uploaded
codefix_env-0.2.3.tar.gz 52.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codefix-env 0.2.3
File Interpreter ABI Platform
codefix_env-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 96.9 kB

Release files / codefix_env-0.2.3.tar.gz

Download URL codefix_env-0.2.3.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4bfa3255aa8e118e5742fea34597c1b7a84ee408c7201c482d550b01902579b1
BLAKE2b-256 checksum
How to use checksums
cf5a249a4c7f272c7d48549ce492be8bc62de38dca61d8730fce49c85203cc2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.

Transparency log

Release files / codefix_env-0.2.3-py3-none-any.whl

Download URL codefix_env-0.2.3-py3-none-any.whl
Size 44.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40b0d3679ebf43e0fa7ea1c1a736d1362e9383538213c00758652443c5c65934
BLAKE2b-256 checksum
How to use checksums
9288f6ed59ca6d3ca4b62850c65e0745a7d9d6f6e94fb0d1e85e82475d95ac43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page