Benchmarks
- Codemode
OFF: Standard Pi (codemode="off") — the model invokes individual tools (read, write, edit, bash, grep, find, ls) one turn at a time.
- Codemode
ON: Strict QuickJS Codemode (codemode="only" + runtime guard) — direct tool calls are blocked; the model writes JavaScript to chain multiple tool calls in a single turn.
1. Multi-File Repo Bug Repair — SWE-smith (n = 30)
Table with columns: Model, Codemode, Full Solve, Avg Score, Avg Turns, Tokens / Solve| Model | Codemode | Full Solve | Avg Score | Avg Turns | Tokens / Solve |
|---|
Qwen/Qwen3.8-27B (Base) | OFF (standard Pi tools) | 23.3% (7/30) | 0.500 | 6.8 | 139.3k |
harness-hub/Qwen3.8-27B-pi-adapted | OFF (standard Pi tools) | 16.7% (5/30) | 0.471 | 4.9 | 131.1k |
harness-hub/Qwen3.8-27B-pi-adapted | ON (zero-shot QuickJS) | 20.0% (6/30) | 0.535 | 5.1 | 117.7k |
Qwen3.8-27B-pi-codemode-adapted (Ours) | ON (Codemode-adapted) | 26.7% (8/30) | 0.564 | 5.2 | 96.7k |
Takeaway: On multi-file repository bug repair, our Codemode adapter reaches 26.7% (8/30) vs. 16.7% (5/30) on pi-adapted with Codemode OFF (+10.0 pp, 3 paired wins / 0 losses) while using 26% fewer tokens per solve (96.7k vs. 131.1k) by chaining search, file reads, edits, and pytest checks inside single turns.
2. Greenfield Package Creation — Traj2Envs (n = 10)
Table with columns: Model, Codemode, Full Solve, Avg Score, Avg Turns, Tokens / Solve| Model | Codemode | Full Solve | Avg Score | Avg Turns | Tokens / Solve |
|---|
Qwen/Qwen3.8-27B (Base) | OFF (standard Pi tools) | 20.0% (2/10) | 0.619 | 6.8 | 265.1k |
harness-hub/Qwen3.8-27B-pi-adapted | OFF (standard Pi tools) | 60.0% (6/10) | 0.740 | 6.0 | 83.6k |
harness-hub/Qwen3.8-27B-pi-adapted | ON (zero-shot QuickJS) | 40.0% (4/10) | 0.558 | 4.6 | 87.6k |
Qwen3.8-27B-pi-codemode-adapted (Ours) | ON (Codemode-adapted) | 40.0% (4/10) | 0.450 | 5.3 | 95.2k |
Takeaway: On greenfield tasks requiring multi-hundred-line Python files from scratch, Codemode OFF (60.0%) outperforms QuickJS-wrapped file writes (40.0%) due to JavaScript string-escaping overhead on large tools.write payloads.
3. Interactive Shell & Build — Terminal-Bench 2.1 (n = 12)
Table with columns: Model, Codemode, Full Solve, Avg Score, Avg Turns, Tokens / Solve| Model | Codemode | Full Solve | Avg Score | Avg Turns | Tokens / Solve |
|---|
Qwen/Qwen3.8-27B (Base) | OFF (standard Pi tools) | 0.0% (0/12) | 0.000 | 9.8 | — |
harness-hub/Qwen3.8-27B-pi-adapted | OFF (standard Pi tools) | 16.7% (2/12) | 0.167 | 8.6 | 257.5k |
harness-hub/Qwen3.8-27B-pi-adapted | ON (zero-shot QuickJS) | 0.0% (0/12) | 0.000 | 6.4 | — |
Qwen3.8-27B-pi-codemode-adapted (Ours) | ON (Codemode-adapted, unconstrained) | 0.0% (0/12) | 0.000 | 6.7 | — |
Qwen3.8-27B-pi-codemode-adapted (Ours · 1-call cap) | ON (PI_MAX_NESTED_CALLS=1) | 25.0% (3/12) | 0.250 | 6.9 | 146.9k |
Takeaway: On interactive shell and compilation tasks where command stdout is unpredictable, chaining multiple speculative shell calls in one JS turn misfires (0/12), whereas capping our exact same v2-folded-rl weights to 1 call per turn (PI_MAX_NESTED_CALLS=1) reaches 25.0% (3/12) vs. 16.7% (2/12) on pi-adapted with Codemode OFF (43% fewer tokens per solve).
4. Real-World Issue Resolution — SWE-bench Verified (n = 12)
Table with columns: Model, Codemode, Full Solve, Avg Score, Avg Turns, Tokens / Solve| Model | Codemode | Full Solve | Avg Score | Avg Turns | Tokens / Solve |
|---|
Qwen/Qwen3.8-27B (Base) | OFF (standard Pi tools) | 58.3% (7/12) | 0.583 | 9.3 | 66.4k |
harness-hub/Qwen3.8-27B-pi-adapted | OFF (standard Pi tools) | 75.0% (9/12) | 0.750 | 6.8 | 42.4k |
harness-hub/Qwen3.8-27B-pi-adapted | ON (zero-shot QuickJS) | 66.7% (8/12) | 0.667 | 8.2 | 68.9k |
Qwen3.8-27B-pi-codemode-adapted (Ours) | ON (Codemode-adapted) | 75.0% (9/12) | 0.750 | 8.7 | 61.3k |
Takeaway: On real-world SWE-bench Verified issues, enabling zero-shot QuickJS on pi-adapted drops solves from 75.0% (9/12) to 66.7% (8/12), whereas our Codemode-adapted LoRA recovers the full 75.0% (9/12) solve rate (+16.7 pp over base Qwen3.8-27B) while staying 100% inside strict QuickJS Codemode.


Training & Single-Call Cap Ablations (Codemode ON)
Table with columns: Strict Codemode Checkpoint, What It Isolates, SWE-smith Solve (n=30), SWE-smith Score, Traj2Envs Solve (n=10), Traj2Envs Score, TB21 Solve (n=12), SWE-bench Solve (n=12)| Strict Codemode Checkpoint | What It Isolates | SWE-smith Solve (n=30) | SWE-smith Score | Traj2Envs Solve (n=10) | Traj2Envs Score | TB21 Solve (n=12) | SWE-bench Solve (n=12) |
|---|
v0-cold-rl-from-pi | Online GRPO from pi-adapted without trajectory-folding SFT | 26.7% (8/30) | 0.526 | 20.0% (2/10) | 0.263 | 8.3% (1/12) | 75.0% (9/12) |
v1-folded-sft | Trajectory-folding SFT warm-up (24 multi-call scripts) before RL | 26.7% (8/30) | 0.540 | 20.0% (2/10) | 0.320 | 8.3% (1/12) | 66.7% (8/12) |
v2-folded-rl (Ours · Root Adapter) | Folded SFT warm-up + turn-budget-scarcity online GRPO | 26.7% (8/30) | 0.564 | 40.0% (4/10) | 0.450 | 0.0% (0/12) | 75.0% (9/12) |
v2-folded-rl (1-call cap) | Identical root weights capped at 1 tool call per JS script (PI_MAX_NESTED_CALLS=1) | 20.0% (6/30) | 0.500 | 30.0% (3/10) | 0.483 | 25.0% (3/12) | 75.0% (9/12) |
Method Overview
- Trajectory-Folding SFT Warm-Up (
v1-folded-sft): In our earlier 9B experiment, running Codemode RL from scratch caused the policy to use QuickJS as a single-call wrapper (0.94 tool calls/script). To seed multi-call composition, we folded contiguous direct-tool trajectories (grep/find → read and read → edit → bash) into 24 replay-verified QuickJS scripts (2.04 calls/script) and ran 12 steps of masked SFT starting from harness-hub/Qwen3.8-27B-pi-adapted.
- Outcome-Only RL Under Turn Scarcity (
v2-folded-rl): Starting from v1-folded-sft, we ran 12 steps of AsyncGRPOTrainer across a 3:1 mix of decontaminated SWE-smith repository repair tasks and Traj2Envs build tasks under tight 4- and 8-turn budgets. Reward is pure test outcome (fail-to-pass fraction gated on zero pass-to-pass regressions), sustaining 23.5% multi-call scripts during RL (vs. 16.5% in cold RL).
- Strict Codemode Runtime Guard (
extensions/strict-codemode-v2.ts): Blocks top-level direct tool calls outside codemode, prompts the agent once per episode if an inspection script forgets to return its output, and supports an optional PI_MAX_NESTED_CALLS=1 cap to isolate the effect of multi-call composition at inference time.
import torchfrom peft import PeftModelfrom transformers import AutoTokenizer, Qwen3_5ForConditionalGeneration base = Qwen3_5ForConditionalGeneration.from_pretrained( "Qwen/Qwen3.8-27B", torch_dtype=torch.bfloat16, device_map="auto")# Root loads v2-folded-rl/checkpoint-12; pass subfolder="v1-folded-sft" or "v0-cold-rl-from-pi/checkpoint-12" for ablationsmodel = PeftModel.from_pretrained(base, "xdannys9/Qwen3.8-27B-pi-codemode-adapted")
# Serve in vLLM and run with Pi 1.5.2 + strict Codemode guardvllm serve Qwen/Qwen3.8-27B --port 8000 --max-model-len 32768 --language-model-only \ --enable-prefix-caching --mamba-cache-mode align --enable-auto-tool-choice \ --tool-call-parser qwen3_xml --reasoning-parser qwen3 \ --default-chat-template-kwargs '{"enable_thinking": false}' \ --enable-lora --max-lora-rank 32 \ --lora-modules qwen38-folded-rl=xdannys9/Qwen3.8-27B-pi-codemode-adapted npm install -g --ignore-scripts @earendil-works/[email protected] [email protected]hf download xdannys9/Qwen3.8-27B-pi-codemode-adapted extensions/strict-codemode-v2.ts --local-dir ./hub pi --provider local-vllm --model qwen38-folded-rl --thinking off \ -e "$(npm root -g)/pi-codemode-guard" -e ./hub/extensions/strict-codemode-v2.ts \ --print "Inspect this repository, run pytest, and fix any failing tests."
Repository Layout
xdannys9/Qwen3.8-27B-pi-codemode-adapted/├── adapter_config.json & adapter_model.safetensors # Root adapter (v2-folded-rl/checkpoint-12, r=32, α=64)├── v1-folded-sft/ # Stage 1 trajectory-folding SFT checkpoint & metrics├── v2-folded-rl/checkpoint-{4,8,12}/ # Stage 2 folded-init RL checkpoints├── v0-cold-rl-from-pi/checkpoint-{4,8,12}/ # Ablation: cold-start RL checkpoints from pi-adapted├── extensions/strict-codemode-v2.ts # Strict Codemode guard & 1-call cap extension├── assets/ # Benchmark & composition plots (PNG + SVG)├── benchmarks/ # Full 7-arm per-task JSON reports & paired summaries└── code/ # Training, trajectory folding & evaluation scripts