A LoRA adapter for Qwen/Qwen3.8-27B, trained with reinforcement learning with thinking on to work as the model behind the pi coding agent on software-engineering and terminal tasks.
It is the thinking counterpart of harness-hub/Qwen3.8-27B-pi-adapted, which was trained with thinking off.
[!Tip] The same accuracy as thinking with the base model or the pi adapter, at 35–42% fewer tokens. On the tasks all three solve, this adapter needs 26.7k output tokens per SWE-bench Pro task where the pi adapter with thinking needs 46.0k (−42%, mean), and 6.9k per Terminal-Bench 2.1 task against 10.7k (−35%, median).
[!Note] All results are under the pi harness: one attempt per task, a 100-step budget, thinking on at the chat template's default effort (
xhigh) with up to 32k output tokens per model call, text only (the vision tower is not served), sampling at temperature 0.8 with top-p 1.0 (the training sampling). These numbers are not comparable with the ones on the Qwen3.8-27B card, which uses other harnesses, larger budgets and the full SWE-bench Pro.
| Benchmark | Qwen3.8-27B | Qwen3.8-27B, thinking | Qwen3.8-27B-pi-adapted | Qwen3.8-27B-pi-adapted, thinking | Qwen3.8-27B-think-pi-adapted |
|---|---|---|---|---|---|
| SWE-bench Pro (hard 51) | 39.2% | 74.5% | 64.7% | 74.5% | 76.5% |
| Terminal-Bench 2.1 (87 tasks) | – | 60.9% | – | 59.8% | 57.5% |
On Terminal-Bench 2.1, the three thinking runs were evaluated together on the same hardware (see
Evaluation checks) and are compared on the 87 tasks all three graded; the runs without thinking were not part
of that re-run. "Thinking" is the chat template's thinking mode at its default reasoning effort (xhigh). This adapter is always
evaluated with thinking on.
One attempt per task, both with thinking on, on the same tasks. Score is pass@1 on the tasks both graded; tool calls and tokens are compared on the tasks both solved, so they measure only how much work each needed. The p-value is an exact sign test on the tasks that changed outcome; the interval is the paired 95% interval on the difference.
| Benchmark | Difference (points) | 95% interval | Newly solved / lost | Tool calls | Output tokens |
|---|---|---|---|---|---|
| SWE-bench Pro (hard 51) | +2.0 | −9.5 to +13.5 | 5 / 4 (p = 1.0) | −7% | −31% |
| Terminal-Bench 2.1 (87 tasks) | −2.3 | −10.7 to +6.1 | 6 / 8 (p = 0.79) | −15%* | −35%* |
*Medians on the 41 Terminal-Bench tasks all three models solved.
Against the base model with thinking: on SWE-bench Pro, +2.0 points, −40% tool calls, −34% output tokens; on Terminal-Bench 2.1, −3.4 points (6 won, 9 lost), −35% tool calls and −19% output tokens (medians).
Output tokens on the tasks all three solveMean output tokens per task (thinking included) on the tasks the base model with thinking, the pi adapter with thinking and this adapter all solved.
| Benchmark | Tasks | Qwen3.8-27B, thinking | Qwen3.8-27B-pi-adapted, thinking | This adapter | vs pi adapter |
|---|---|---|---|---|---|
| SWE-bench Pro (hard 51) | 28 | 45.8k | 46.0k | 26.7k | −42% |
On Terminal-Bench 2.1, on the 41 tasks all three solved in the matched re-run, the medians are 8.5k (base), 10.7k (pi adapter) and 6.9k for this adapter (−35%). On SWE-bench Pro the medians are 25.3k against 38.8k.
How it thinksOne SWE-bench Pro task both models solved with thinking on (gravitational/teleport): each bar is one model call, its
height the call's output tokens, thinking included. This adapter solves it in 47 calls and 28.6k tokens, the pi adapter
in 82 calls and 82.1k. It is the task with the largest saving among those both solved; across the tasks all three
solved, the saving is about 40%.
On the 18 SWE-bench Pro tasks all three solved and have a full trajectory for:
| Qwen3.8-27B, thinking | Qwen3.8-27B-pi-adapted, thinking | This adapter | |
|---|---|---|---|
| Turns per task (median) | 70 | 60 | 47 |
| Output tokens per task (median) | 54k | 54k | 33k |
| Model calls over 1k output tokens | 20% | 24% | 18% |
| Model calls over 8k output tokens | 0.9% | 1.3% | 0.6% |
The adapter still thinks, but in shorter blocks and over fewer turns.
Evaluation checksvllm serve Qwen/Qwen3.8-27B \
--enable-lora --max-lora-rank 32 \
--lora-modules qwen3.8-think-pi=harness-hub/Qwen3.8-27B-think-pi-adapted \
--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": true}' \
--max-model-len 131072
This is the configuration of the evaluations. Thinking on is what this adapter was trained for. Prefix caching on this
hybrid model needs --mamba-cache-mode align; without it, every agent turn re-reads its whole history.
Install pi (Node.js 22.19 or newer):
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
Add the server to ~/.pi/agent/models.json:
{
"providers": {
"local": {
"baseUrl": "http://localhost:8000/v1",
"api": "openai-completions",
"apiKey": "dummy",
"models": [{ "id": "qwen3.8-think-pi", "reasoning": true, "maxTokens": 32768 }]
}
}
}
"api": "openai-completions": without it pi uses the Responses API, which this adapter was not trained or evaluated
with."maxTokens": 32768: the per-call output cap of training and evaluation. A lower cap cuts long reasoning short.pi --provider local --model qwen3.8-think-pi --print "Find out why the tests in tests/test_parser.py fail and fix the bug."
The adapter can be merged into the base weights with PEFT. The result is a regular Qwen3.8-27B checkpoint (about 54 GB in BF16) that any engine serves without LoRA support:
import torch
from peft import PeftModel
from transformers import AutoModelForImageTextToText, AutoTokenizer
base = AutoModelForImageTextToText.from_pretrained("Qwen/Qwen3.8-27B", dtype=torch.bfloat16, device_map="cpu")
model = PeftModel.from_pretrained(base, "harness-hub/Qwen3.8-27B-think-pi-adapted").merge_and_unload()
model.save_pretrained("Qwen3.8-27B-think-pi-merged")
AutoTokenizer.from_pretrained("harness-hub/Qwen3.8-27B-think-pi-adapted").save_pretrained("Qwen3.8-27B-think-pi-merged")
Then serve it like the base model, without the LoRA flags and with thinking on.
| Method | AsyncGRPO (TRL, experimental), LoRA |
| Environment | Harbor tasks served by OpenEnv, rollouts in HF sandboxes, tool calls screened by safeagents |
| Harness | pi |
| Tasks | 750 scale800 tasks interleaved with 300 TermGrade tasks |
| Reward | the task verifier's correctness (falls back to reward), plus a tool-efficiency bonus of weight 0.1; no length penalty |
| Steps | 90 (this checkpoint) |
| Learning rate | 2e-5 |
| LoRA | r = 32, alpha = 64, on q, k, v, o, gate, up and down projections |
| Rollouts | 8 per task, temperature 0.8, thinking on (xhigh), up to 32,768 output tokens per model call, 50 agent steps and 1,800 s per rollout |
| Batch | 16 micro-batches of up to 65,536 tokens per step, rollouts up to 16 policy versions stale |
| Hardware | 2× NVIDIA H200 (HF Jobs): vLLM on one, the trainer on the other |
The only change from Qwen3.8-27B-pi-adapted's recipe is
thinking on during rollouts, with the larger per-call output cap it needs. The training script is
examples/async_grpo_harbor in TRL.