Configuration Parsing Warning:In adapter_config.json: "peft.task_type" must be a string

Qwen3.5-9B Pi Codemode β€” Harness Adapters

Qwen3.5-9B-pi-codemode-adapted contains LoRA harness adapters (r=32, Ξ±=64) trained with TRL AsyncGRPOTrainer and OpenEnv 0.7.0 to adapt Qwen/Qwen3.5-9B to Pi's QuickJS Codemode (await tools.read/write/edit/bash(...) composed in a single JavaScript turn). Following the Harness Adapters protocol, we report 398 evaluation rollouts (396 verified) across 4 benchmarks (Traj2Envs n=10, Terminal-Bench 2.1 n=12, SWE-smith oauthlib n=30, and SWE-bench Verified Easy n=12) to measure task reward transfer alongside harness interface transfer. The repository root (/) contains the root adapter (v3-repo-strict-codemode/checkpoint-12), while v1-unconstrained/, v2-strict-codemode/, and v3-repo-strict-codemode/ preserve all stage checkpoints.

Empirical Summary

  • 1. Undeclared-Tool Escape Hatch (v1) and Depth-Gated Enforcement (v2): In default Pi (codemode.mode="only"), individual tools (write, bash, read, edit) remain registered in the runtime dispatcher so QuickJS can call them internally. During v1-unconstrained GRPO (12 steps, 48 train tasks), policy exploration bypassed QuickJS syntax errors by invoking undeclared direct tools at the top level (0.0 Codemode calls/rollout at Step 12, 0.152 mean reward on held-out Traj2Envs, n=10). Adding a 13-line execution-depth gate (extensions/strict-codemode.ts) and pi-codemode-guard in v2-strict-codemode blocked top-level non-codemode calls (depth === 0); across Steps 0 β†’ 4 β†’ 8 β†’ 12, held-out Traj2Envs (n=10) mean reward increased from 0.000 β†’ 0.044 β†’ 0.074 β†’ 0.144 (0% β†’ 50% partial progress) and QuickJS script completion changed from 33.3% β†’ 41.2% β†’ 92.3% β†’ 70.4%.
  • 2. Out-of-Distribution Task Reward (v1 Direct-Tool RL): Without the strict depth gate, v1 Step 12 improved over base Qwen3.5-9B on three out-of-distribution benchmarks: Terminal-Bench 2.1 (n=12, E2B) full solve rate increased from 0.0% (0/12) β†’ 16.7% (2/12) (cancel-async-tasks, cobol-modernization), SWE-smith oauthlib (n=30, local) mean F2P reward increased from 0.287 β†’ 0.313 (10.0% [3/30] β†’ 13.3% [4/30] full solves; exact file localization 63.3% β†’ 70.0%), and SWE-bench Verified Easy (n=12, E2B) full solve rate increased from 0.0% (0/12) β†’ 8.3% (1/12) (django__django-11066).
  • 3. Harness Interface Transfer and Repository Inspection Negative Result (v2 Strict QuickJS RL): Under enforced QuickJS execution, v2 Step 12 increased Codemode call share relative to base_strict_guard across all 4 benchmarks: 28.3% β†’ 70.8% on Traj2Envs (n=10), 40.2% β†’ 70.4% on Terminal-Bench 2.1 (n=12, reducing hallucinated code tool calls from 15 β†’ 0), 37.7% β†’ 63.3% on SWE-smith (n=30, script completion 50.4% β†’ 62.6%), and 30.0% β†’ 62.5% on SWE-bench Verified (n=12, script completion 42.4% β†’ 58.7%). However, v2 Step 12 achieved 0.000 mean reward (0% solve) on all three out-of-distribution repository benchmarks: because Traj2Envs training tasks were greenfield builds where await tools.write(...) succeeded without returning a value, the policy frequently omitted return before await tools.read/bash(...) when inspecting unfamiliar repositories, yielding empty [undefined] observations to Pi.
  • 4. Repository-Adapted Strict QuickJS RL (v3-repo-strict-codemode) and Zero-Shot Unseen-Repository Transfer: Warm-starting from v2-strict-codemode/checkpoint-12 for 12 steps (17m 48s on 1Γ— 80 GB A100 BF16, lr=1.5e-5, max_model_len=16384) on 14 oracle+empty-verified SWE-smith oauthlib tasks filtered for zero changed-line overlap against all 30 held-out COMBINE30 gold patches (train_v3_swesmith.py, rewarding has_script_output + loc_hit + regression-gated F2P) closed the return-omission gap under strict QuickJS enforcement:
    • Held-out SWE-smith oauthlib (combine30, n=30): Monotonic progression from v2 Step 12 (0.000 F2P) β†’ v3 Step 4 (0.000 F2P, 6.7% exact loc, 80.7% Codemode share, 65.0% JS completion) β†’ v3 Step 8 (0.019 F2P, 6.7% partial, 16.7% exact loc, 88.3% Codemode share, 73.1% JS completion) β†’ v3 Step 12 (0.299 F2P [29.9%], 10.0% [3/30] full solves, 46.7% [14/30] partial progress, 66.7% [20/30] exact file localization, 89.6% Codemode share, 79.1% JS completion, 29/30 verified), exceeding base_unconstrained (0.287) while operating strictly inside QuickJS.
    • Zero-shot unseen-repository transfer on SWE-bench Verified Easy-12 (n=12, E2B): v3 Step 12 achieved 0.250 mean reward (25.0% = 3/12 full solves: django__django-11066, sympy__sympy-16766, sphinx-doc__sphinx-8475, plus f2p_frac = 1.0 on pytest-dev__pytest-7432; mean_f2p_frac = 0.333, loc_exact = 33.3%, 87.5% Codemode share, 86.7% JS completion, 0.94 nested calls/script, 12/12 verified, 0 errors) β€” compared against 0.0% (0/12) for base_unconstrained, 0.0% (0/12) for base_strict_guard, 8.3% (1/12) for v1_unconstrained, and 0.0% (0/12) for v2_strict_guard.

Traj2Envs Strict Codemode Progression

4-Benchmark Generalization Matrix

// extensions/strict-codemode.ts β€” 13-line execution-depth gate blocking top-level direct tool calls
export default function strictCodemode(pi: any) {
  let depth = 0;
  pi.on("tool_execution_start", (ev: any) => { if (ev.toolName === "codemode") depth++; });
  pi.on("tool_execution_end", (ev: any) => { if (ev.toolName === "codemode") depth = Math.max(0, depth - 1); });
  pi.on("tool_call", async (ev: any) => {
    if (ev.toolName !== "codemode" && depth === 0)
      return { block: true, reason: `Direct tool "${ev.toolName}" blocked. Use "codemode": await tools.${ev.toolName}(...);` };
  });
}

Benchmarks (398 Evaluation Rollouts, 396 Verified Across 4 Benchmarks)

1. Stage 1 & 2 In-Distribution RL Progression: Traj2Envs Held-Out (n=10, 80 Rollouts Across Checkpoints)

Evaluated on 10 held-out Python build and bug-fix tasks (temperature=0.7, 1 attempt/task, agent_step_limit=7, max_completion_length=6144, agent_timeout=120s, 14–20 hidden pytest tests/task; reward = passed / total_tests).

Run Mean Reward Full Solve % Partial Progress % Mean Tool Calls Mean Codemode Calls (Share) Mean Direct Calls QuickJS Script Success % Report
Step 0 Β· Base Qwen3.5-9B (Unconstrained) 0.086 0% 40% 5.3 0.0 (0.0%) 5.3 β€” JSON
v1 Unconstrained Β· Step 4 0.000 0% 0% 5.4 0.1 (1.9%) 5.3 0.0% JSON
v1 Unconstrained Β· Step 8 0.007 0% 10% 4.7 0.3 (6.4%) 4.4 0.0% JSON
v1 Unconstrained Β· Step 12 0.152 0% 40% 4.8 0.0 (0.0%) 4.8 β€” JSON
v2 Strict+Guard Β· Step 0 (Base) 0.000 0% 0% 4.6 1.3 (28.3%) 3.3 33.3% JSON
v2 Strict+Guard Β· Step 4 0.044 0% 10% 4.5 2.1 (46.7%) 2.4 41.2% JSON
v2 Strict+Guard Β· Step 8 0.074 0% 30% 4.3 3.3 (76.7%) 1.0 92.3% JSON
v2 Strict+Guard Β· Step 12 0.144 0% 50% 4.8 3.4 (70.8%) 1.4 70.4% JSON

2. Repository Adaptation (v3) & Multi-Benchmark Generalization (318 Rollouts, 316 Verified)

Evaluation across Terminal-Bench 2.1 (Harbor E2B, n=12, rev 3e235dff, max_turns=10), SWE-smith oauthlib (combine30 held-out local evaluation, n=30, commit 8ea2520a, agent_step_limit=10 [up to 20 tool calls], Summary JSON), and SWE-bench Verified Easy (Harbor E2B zero-shot unseen-repository evaluation, n=12, rev 86723674, max_turns=10, Summary JSON).

Benchmark (n) Run Configuration Verified / Errors Mean Reward (F2P) Full Solve % (Count) Partial Progress % Mean Tool Calls Mean Codemode Calls (Share) Mean Direct Calls QuickJS Success % Loc Exact % Report
Terminal-Bench 2.1 (n=12, E2B) base_unconstrained 12/12 Β· 0 0.000 0.0% (0/12) 0.0% 10.1 0.6 (5.8%) 9.5 β€”* β€” JSON
Terminal-Bench 2.1 (n=12, E2B) base_strict_guard 12/12 Β· 0 0.000 0.0% (0/12) 0.0% 11.0 4.4 (40.2%) 6.6 (15 code) β€”* β€” JSON
Terminal-Bench 2.1 (n=12, E2B) v1_unconstrained (Step 12) 12/12 Β· 0 0.167 16.7% (2/12) 16.7% 10.3 0.5 (4.8%) 9.8 β€”* β€” JSON
Terminal-Bench 2.1 (n=12, E2B) v2_strict_guard (Step 12) 12/12 Β· 0 0.000 0.0% (0/12) 0.0% 9.0 6.3 (70.4%) 2.7 (0 code) β€”* β€” JSON
SWE-smith oauthlib (n=30, local) base_unconstrained 30/30 Β· 0 0.287 10.0% (3/30) 50.0% 18.2 0.1 (0.4%) 18.2 100.0% 63.3% JSON
SWE-smith oauthlib (n=30, local) base_strict_guard 30/30 Β· 0 0.000 0.0% (0/30) 0.0% 20.0 7.5 (37.7%) 12.5 50.4% 0.0% JSON
SWE-smith oauthlib (n=30, local) v1_unconstrained (Step 12) 30/30 Β· 0 0.313 13.3% (4/30) 53.3% 18.3 0.0 (0.0%) 18.3 β€” 70.0% JSON
SWE-smith oauthlib (n=30, local) v2_strict_guard (Step 12) 30/30 Β· 0 0.000 0.0% (0/30) 0.0% 20.0 12.7 (63.3%) 7.3 62.6% 0.0% JSON
SWE-smith oauthlib (n=30, local) v3_step4_strict_guard (Step 4) 30/30 Β· 0 0.000 0.0% (0/30) 0.0% 20.1 16.2 (80.7%) 3.9 65.0% 6.7% JSON
SWE-smith oauthlib (n=30, local) v3_step8_strict_guard (Step 8) 30/30 Β· 0 0.019 0.0% (0/30) 6.7% 19.9 17.6 (88.3%) 2.3 73.1% 16.7% JSON
SWE-smith oauthlib (n=30, local) v3_strict_guard (Step 12, Root Adapter) 29/30 Β· 1 0.299 10.0% (3/30) 46.7% 19.2 17.2 (89.6%) 2.0 79.1% 66.7% JSON
SWE-bench Verified (n=12, E2B) base_unconstrained 12/12 Β· 0 0.000 0.0% (0/12) 0.0% 10.0 0.0 (0.0%) 10.0 β€” 0.0% JSON
SWE-bench Verified (n=12, E2B) base_strict_guard 11/12 Β· 1 0.000 0.0% (0/12) 0.0% 9.2 2.75 (30.0%) 6.42 42.4% 0.0% JSON
SWE-bench Verified (n=12, E2B) v1_unconstrained (Step 12) 12/12 Β· 0 0.083 8.3% (1/12) 8.3% 10.0 0.0 (0.0%) 10.0 β€” 16.7% JSON
SWE-bench Verified (n=12, E2B) v2_strict_guard (Step 12) 12/12 Β· 0 0.000 0.0% (0/12) 0.0% 10.0 6.25 (62.5%) 3.75 58.7% 0.0% JSON
SWE-bench Verified (n=12, E2B) v3_strict_guard (Step 12, Root Adapter) 12/12 Β· 0 0.250 (0.333†) 25.0% (3/12) 25.0% 10.0 8.75 (87.5%) 1.25 86.7% 33.3% JSON

*Harbor JSON-mode capture on Terminal-Bench 2.1 did not parse QuickJS Script completed / Script failed prefixes; script completion was recorded on SWE-smith and SWE-bench Verified. Under strict_guard, top-level direct calls are counted when emitted even though strict-codemode.ts blocks them before execution. †On SWE-bench Verified Easy-12, v3_strict_guard achieved mean_reward = 0.250 (3/12 full solves: django__django-11066, sympy__sympy-16766, sphinx-doc__sphinx-8475) and mean_f2p_frac = 0.333 (4/12 tasks with f2p_frac = 1.0, including pytest-dev__pytest-7432 which had p2p_frac = 0.987), with 0.94 nested tool calls per Codemode script.


Repository Layout

xdannys9/Qwen3.5-9B-pi-codemode-adapted/
β”œβ”€β”€ adapter_config.json & adapter_model.safetensors   # Root adapter weights (v3-repo-strict-codemode/checkpoint-12, r=32, Ξ±=64)
β”œβ”€β”€ v1-unconstrained/checkpoint-{4,8,12}/             # Stage 1 PEFT checkpoints (unconstrained direct-tool escape hatch)
β”œβ”€β”€ v2-strict-codemode/checkpoint-{4,8,12}/           # Stage 2 PEFT checkpoints (depth-gated QuickJS Codemode RL on Traj2Envs)
β”œβ”€β”€ v3-repo-strict-codemode/checkpoint-{4,8,12}/      # Stage 3 PEFT checkpoints (disjoint SWE-smith repo QuickJS RL) & metrics.jsonl
β”œβ”€β”€ extensions/strict-codemode.ts                     # 13-line Pi extension blocking top-level non-codemode tool calls
β”œβ”€β”€ assets/                                           # Benchmark plots (PNG + SVG)
β”‚   β”œβ”€β”€ traj2envs_progression.{png,svg}
β”‚   └── cross_benchmark_matrix.{png,svg}
β”œβ”€β”€ benchmarks/
β”‚   β”œβ”€β”€ traj2envs/                                    # Held-out Traj2Envs (n=10) eval_00..12 JSONs & metrics_v{1,2}.jsonl
β”‚   β”œβ”€β”€ terminal-bench-2.1/                           # Paired 4-way Terminal-Bench 2.1 (E2B, n=12) rollout reports
β”‚   β”œβ”€β”€ swesmith-oauthlib/                            # SWE-smith oauthlib (n=30) base/v1/v2/v3-step{4,8,12} reports & summary
β”‚   └── swebench-verified-easy30/                     # SWE-bench Verified (n=12) base/v1/v2/v3 reports & summary
└── code/                                             # Training & evaluation scripts (OpenEnv + Harbor E2B + train_v3_swesmith.py)

Quickstart: vLLM + pi (@earendil-works/pi-coding-agent@1.5.2)

# 1. Serve Qwen/Qwen3.5-9B + LoRA adapter in vLLM
vllm serve Qwen/Qwen3.5-9B \
  --host 127.0.0.1 --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 qwen3.5-pi-codemode=xdannys9/Qwen3.5-9B-pi-codemode-adapted

# 2. Install Pi Codemode CLI + Guard and configure strict-codemode.ts
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@1.5.2 pi-codemode-guard
export PI_CODING_AGENT_DIR="$(mktemp -d)"
hf download xdannys9/Qwen3.5-9B-pi-codemode-adapted extensions/strict-codemode.ts --local-dir "$PI_CODING_AGENT_DIR/hub"

cat > "$PI_CODING_AGENT_DIR/models.json" <<'JSON'
{"providers":{"local-vllm":{"baseUrl":"http://127.0.0.1:8000/v1","api":"openai-completions","apiKey":"local","models":[{"id":"qwen3.5-pi-codemode","contextWindow":32768,"maxTokens":6144}]}}}
JSON

cat > "$PI_CODING_AGENT_DIR/settings.json" <<'JSON'
{"defaultTools":["read","bash","edit","write","grep","find","ls","codemode"],"codemode":{"mode":"only","inlineBudget":3000},"compaction":{"enabled":false}}
JSON

pi --provider local-vllm --model qwen3.5-pi-codemode --thinking off \
  -e "$(npm root -g)/pi-codemode-guard" \
  -e "$PI_CODING_AGENT_DIR/hub/extensions/strict-codemode.ts" \
  --print "Inspect this repository, run the test suite, and summarize any failing tests."

Training Hyperparameters & Provenance

Parameter Stage 1 & 2 (v1-unconstrained, v2-strict-codemode) Stage 3 (v3-repo-strict-codemode, Root Adapter)
Base / Warm-Start Qwen/Qwen3.5-9B (enable_thinking=False) on 1Γ— A100-SXM4-80GB (BF16) Warm-started from v2-strict-codemode/checkpoint-12 on 1Γ— A100-SXM4-80GB (BF16)
RL Trainer & Capture TRL HarnessAsyncGRPOTrainer (AsyncGRPOConfig, adamw_torch) + OpenEnv 0.7.0 CaptureServer (capture_level="tokens") Same (train_v3_swesmith.py, use_tree_packing=True, max_model_len=16384)
Harness & Extensions @earendil-works/pi-coding-agent@1.5.2 (codemode.mode="only", inlineBudget=3000); v2 adds pi-codemode-guard + strict-codemode.ts Same strict depth-gated QuickJS harness (strict-codemode.ts + pi-codemode-guard)
LoRA Config r=32, lora_alpha=64, exclude_modules=".*visual.*", targets: {q,k,v,o,gate,up,down}_proj Same (r=32, lora_alpha=64)
Dataset & Decontamination 48 Traj2Envs train tasks / 10 held-out tasks (oracle β‰₯ 0.99, empty == 0.0) 14 oracle+empty-verified SWE-smith oauthlib tasks filtered for zero changed-line overlap against all 30 held-out COMBINE30 gold patches
Optimization & Runtime lr=2e-5, batch_size=1, grad_accum=2, num_generations=4, temperature=0.85 (train) / 0.7 (eval), 12 steps (37m v1 / 59m v2) lr=1.5e-5, batch_size=1, grad_accum=2, num_generations=4, temperature=0.85 (train) / 0.7 (eval), 12 steps (17m 48s)
Rollout & Sandbox Limits max_concurrent_rollouts=6, max_staleness=4, max_completion_length=6144, agent_step_limit=7, nobody privilege drop + 0700 test lock max_concurrent_rollouts=6, max_staleness=2, max_completion_length=4096, agent_step_limit=10, agent_timeout=240s, nobody privilege drop
Reward Function r = correctness if correctness < 1.0 else 1.0 + 0.15 * max(0, 1 - tool_calls / 5.0) Regression-gated env_reward (F2P when P2P == 1.0) + milestones (has_script_output, loc_hit, completed nested calls; cap 0.12) - 0.008 * min(direct_calls, 5) + full-solve efficiency bonus

Limitations & Citation

  • Greenfield-write (v2) vs. repository-read (v3) return behavior: v2 Step 12 increased QuickJS codemode call share (62.5–70.8% across all 4 benchmarks) but frequently omitted return from await tools.read/bash(...) scripts when inspecting existing repositories (0.000 reward on Terminal-Bench 2.1, SWE-smith, and SWE-bench Verified). Warm-starting v3 on 14 disjoint SWE-smith repository tasks with has_script_output and loc_hit shaping recovered strict-Codemode task reward on held-out SWE-smith oauthlib (0.299 F2P, 10.0% full solves) and transferred zero-shot to unseen repositories on SWE-bench Verified Easy-12 (0.250 reward, 25.0% full solves, 0.333 mean F2P).
  • Turn budget, P2P regressions, and residual direct calls: Under a 10-turn limit, v3 Step 12 exhausted the turn budget on 80% of SWE-smith rollouts and 100% of SWE-bench Verified rollouts, and averaged 1.25–2.0 blocked top-level direct tool attempts per rollout before switching to codemode. On pytest-dev__pytest-7432, v3 passed all fail-to-pass tests (f2p_frac = 1.0) but introduced one pass-to-pass regression (p2p_frac = 0.987), yielding 0.0 under strict SWE-bench binary grading. Execute model-generated QuickJS and bash commands inside isolated containers (Docker or E2B).
@misc{qwen35_pi_codemode_adapted_2026,
  title        = {Qwen3.5-9B Pi Codemode Harness Adapters: Closing the Undeclared-Tool Escape Hatch with Execution-Depth-Gated QuickJS RL},
  author       = {xdannys9},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/xdannys9/Qwen3.5-9B-pi-codemode-adapted}}
}
Downloads last month
139
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for xdannys9/Qwen3.5-9B-pi-codemode-adapted

Finetuned
Qwen/Qwen3.5-9B
Adapter
(1,199)
this model