Code Contests Environment
CodeContestsEnvironment (halo/environments/tasks/coding/code_contests.py) trains competitive
programming. The model tries a solution in a scratchpad tool and submits it with submit_solution, which runs it
against the hidden tests in a sandbox. The reward's environment term pays 1 when the
submission passes every hidden test, else 0.
Two registry names share the class: code_contests (output_comparison: exact) and codeforces (token
comparison). The environment speaks native tool calls, so the server needs a
tool-call parser for the model family.
Recipes ship under examples/grpo/environmental/<family>/<backend>/. The canonical one is
examples/grpo/environmental/gptoss/vllm/gptoss-20b-code-contests-lora-ep1.yaml.
Configuration
YAML
environment_type: codeforces
max_turns: 16
environment_kwargs:
language: python # or cpp / c, or a list ([python, cpp])
timeout_per_test: 5
max_grading_seconds: 150
reasoning_effort: random
reasoning_effort_profiles: # reasoning_budget: an episode's free reasoning tokens; reasoning_price: per 1,000 past it
low: {reasoning_budget: 40000, reasoning_price: 0.008, max_submissions: 1, max_test_calls: 2}
medium: {reasoning_budget: 50000, reasoning_price: 0.006, max_submissions: 2, max_test_calls: 4}
high: {reasoning_budget: 60000, reasoning_price: 0.004, max_submissions: 3, max_test_calls: 6}
rewards:
- source: environment
- source: judge # the audit veto
name: audit
checks: environment # the environment's rubric: Reward → Audit judgetimeout_per_test, max_time_limit and compiled_time_limit_scale must be finite and > 0; a non-positive
max_grading_seconds raises too, at construction.
sandbox_backend / sandbox_url pick the sandbox both tools and the
grader run on. A backend that does not confine the program, local included, warns.
Reasoning effort
reasoning_effort defaults to medium here. The class sets no per-level defaults: a profile's reasoning_budget
and reasoning_price are the reasoning length terms, and the chat
template states the level alone (Effort templates).
Two profile keys make a higher level buy iteration, not only reasoning: max_submissions (int ≥ 1, graded
submit_solution calls) and max_test_calls (int ≥ 0, scratchpad runs).
- Both are bound at reset and enforced per call; where the level is undetermined at reset, the constructor's budgets stand. A value below its minimum raises at construction.
- Neither is stated to the model. A call past its budget is refused.
Shipped recipes
Every recipe runs one economy, pinned by a CPU test (Economy invariants). The
curriculum recipes are the three Qwen3.6 vLLM stages
(*-stage1-codeforces, *-stage2-hard, *-stage3-extra-hard).
Pages
Source on GitHubUpdated 18 November 2026