NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CRANE: Constrained Reasoning Injection for Code Agents via Nullspace Editing

Mingzhi Zhu, Michele Merler, Raju Pavuluri, Stacy PattersonNeurIPS 2026

TL;DR

Modern AI code agents face an annoying Catch-22: standard "Instruct" models follow strict tool formatting cleanly but jump into edits without enough forethought, while reasoning-heavy "Thinking" models plan brilliantly yet overthink themselves into huge token bills and broken JSON calls. CRANE solves this without retraining a single weight. By surgically grafting only the helpful planning parameters from a Thinking model into an Instruct model—while mathematically shielding the pathways responsible for tool syntax—it produces an agent that solves significantly more software bugs faster and cheaper than either parent model alone.

What Problem Does This Paper Address?

Imagine deploying an autonomous software engineer. To succeed, it needs two distinct skills: deep, multi-step reasoning over a sprawling codebase, and crisp obedience to strict tool-calling protocols (like outputting exact JSON schemas and knowing when to stop talking and run pytest).

Right now, model families often ship with paired checkpoints: an Instruct version and a Thinking version. In agentic coding, their strengths are misaligned:

  • Instruct models are disciplined and concise with tools, but often act impulsively—editing code before reading the test suite and looping blindly when things break.
  • Thinking models excel at reflection and planning, yet frequently spiral into massive monologues (generating ~2.7$\times$ more tokens), blow past context budgets, or emit malformed tool payloads—actually scoring lower than their Instruct siblings.
Qualitative trace comparing how Instruct, Thinking, and CRANE handle a Python coding task.

Standard "model merging" techniques try to blend two models symmetrically. However, blindly averaging their weights corrupts the Instruct model's delicate formatting habits. The challenge is asymmetric, behavior-conditioned editing: how do we import only the Thinking model's planning instincts while keeping the Instruct model's crisp tool interface completely intact?

Methods

CRANE (Constrained Reasoning Injection for Code Agents via Nullspace Editing) is a training-free recipe that treats the weight difference between the paired checkpoints ($\delta = \theta_{\text{think}} - \theta_{\text{inst}}$) not as a destination, but as a pool of candidate edits to apply to $\theta_{\text{inst}}$.

Figure 2: CRANE implementation pipeline with three stages: (1) Magnitude thresholding to sparsify δ and discard low-confidence coordinates; (2) Conservative Taylor Gate that sets per-block injection strength according to how much of the block’s edit is first-order beneficial to both reasoning and tool use; (3) Graduated Sigmoidal Projection that attenuates updates along format-critical subspaces.

Using three tiny calibration sets—capturing reasoning traces ($\mathcal{D}_R$), agent action timing ($\mathcal{D}_A$), and syntax/format tokens ($\mathcal{D}_F$)—CRANE filters $\delta$ through three stages:

  1. Magnitude Thresholding (Standard): It zeroes out the smallest 50% of parameter differences in $\delta$ and rescales the survivors by 2, stripping away low-confidence noise.
  2. Conservative Taylor Gate / CTG (Novel): Using first-order gradients on $\mathcal{D}_R$ and $\mathcal{D}_A$, CRANE checks whether nudging each weight toward the Thinking value reduces both reasoning loss and tool-behavior loss. Only mutually beneficial coordinates get a positive vote, determining a custom injection strength for every transformer block.
  3. Graduated Sigmoidal Projection / GSP (Novel): Even careful weight scaling can break JSON braces or chat delimiters. CRANE records input activations at format-critical tokens ($\mathcal{D}_F$), finds their dominant directions via Singular Value Decomposition (SVD), and passes the proposed weight update through a smooth sigmoid filter in singular-value space. Unlike hard nullspace cutoffs used in prior continual-learning work, this soft spectral shield gently attenuates protocol-drifting directions without jarring long-context agent behavior.

Datasets

Because CRANE is training-free, no training datasets are used (only small calibration traces, built without benchmark leakage). The authors evaluate on three established, existing agentic coding benchmarks (no new benchmarks are introduced):

  • Roo-Eval: A 5-language, in-IDE coding benchmark (195 exercises).
  • SWE-bench-Verified (SWE-V): 500 real-world GitHub repository issue-resolution tasks (run via OpenHands).
  • Terminal-Bench v2 (TB-V2): 89 long-horizon, sandboxed command-line shell tasks (tb2-zai split).

Key Insights and Ideas

  • Smarter agents can actually cost less: You might expect injecting "Thinking" weights to inflate output length. Instead, CRANE often reduces total tokens and wall-clock time compared to the concise Instruct model—because reading specifications first prevents 20 rounds of frantic, failed debugging loops!
  • Prompting or capping Thinking models isn't enough: Simply truncating or skipping a Thinking model's chain-of-thought at inference time tops out at 106/195 on 30B Roo-Eval (pass@3), far behind CRANE's 162/195. The behavioral mismatch lives deep in the weights.
  • Surgical weight editing beats lightweight fine-tuning: Training QLoRA adapters on ~800 successful trajectories took ~8–10 GPU-hours and failed to beat the Instruct baseline. CRANE took 0.4 GPU-hours and crushed both.
  • Format subspaces are fragile: Removing GSP caused chat-template and tool-call delimiters to leak into 118/195 Roo-Eval tasks (compared to just 3/195 with GSP), tanking task success by nearly 15 percentage points.

Key Results

Evaluated on two MoE architectures—Qwen3-30B-A3B and Qwen3-Next-80B-A3B—CRANE consistently outperforms both original checkpoints and six merging baselines (including Task Arithmetic, TIES, SLERP, and RAIN):

  • Roo-Eval (pass@1): Jumps from 46.7% (Instruct) and 34.9% (Thinking) to 66.2% (+19.5%) at 30B, while cutting aggregate token footprint by ~33%. At 80B, it hits 81.5% (+8.7% over Instruct).
  • SWE-bench-Verified: Resolves 122/500 instances at 30B (+14 over Instruct, +75 over Thinking) while slashing total token cost by over half (5.68B vs. 12.04B). At 80B, it reaches 180/500 (+12 over Instruct).
  • Terminal-Bench v2: Boosts pass@1/pass@5 to 7.6% / 18.0% at 30B (finishing nearly 2 hours faster than Instruct) and 14.8% / 30.3% at 80B.

Limitations and Future Work

  • Same-architecture requirement: Both checkpoints must share exact parameterizations (typically fine-tuned from the same base model). Cross-family merging would require weight-alignment techniques.
  • Structured protocols only: Calibration sets must match the deployed tool syntax; unstructured, free-form generation tasks fall outside CRANE's scope.
  • Inherited blind spots & backward-pass compute: Calculating Taylor gradients requires backward passes (~6 min at 30B, ~27 min at 80B). Additionally, CRANE can inherit language-specific weaknesses—for example, trailing the 30B Instruct model on Java tasks where the Thinking model struggled most.
  • Future directions: Exploring cross-family alignment and analyzing which specific layers house reasoning versus protocol fidelity.

Summary updated

BibTeX
@inproceedings{zhu2026crane,
  author = {Mingzhi Zhu and Michele Merler and Raju Pavuluri and Stacy Patterson},
  title = {{CRANE: Constrained Reasoning Injection for Code Agents via Nullspace Editing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=5QIRV0FZpg},
}
Figure