SheetCraft: Fine-Tuning Code Agents for Execution-Guided Spreadsheet Reasoning and Construction

Zuowei Zhang, Xiaotian Li, Siyuan Li, Enhao Gu, Kexu Cheng, Hanbo Song, Yule ZhangarXiv 2026

TL;DR

Asking an AI to read a static spreadsheet is yesterday's solved problem; asking it to build a living spreadsheet ecosystem—complete with linked tables, views, dashboards, workflows, and permissions—is a chaotic engineering minefield. SheetCraft introduces a framework that fine-tunes a 27B-parameter code agent to iteratively write, test, and repair TypeScript code against a real spreadsheet sandbox. By learning from execution feedback rather than just mimicking syntax, this compact model matches or beats massive proprietary frontier models at constructing complex, persistent spreadsheet states.

What Problem Does This Paper Address?

For years, "table AI" meant Question Answering: feed a static CSV into a model, ask "Which store sold the most in May?", and get a text string back.

Real-world operational spreadsheets are much messier. They are stateful, interconnected applications. When a user asks an assistant to set up a store management tracker, add a sales summary dashboard, and configure automated reminder workflows, the output isn't a sentence—it's a mutated, persistent digital artifact.

Figure 1: SheetCraft assists users with spreadsheet manipulation and reasoning tasks.

One-shot code generation falls apart here. A tiny hallucination in a column ID, an out-of-order schema edit, or a broken cross-table reference in Turn 1 will silently cascade and ruin the dashboard in Turn 3—even if the generated code looks syntactically plausible. Agents need a way to interact with an actual spreadsheet environment, observe concrete compiler and runtime crashes, and repair their own mistakes over multiple turns.

Methods

SheetCraft reframes spreadsheet construction as an execution-guided code-agent task. Instead of guessing edits blindly, the agent writes TypeScript programs against a typed SDK to modify a cloned spreadsheet base.

Figure 2: Overview of the SheetCraft training, budgeted multi-turn execution, and artifact-grounded evaluation pipeline.

What makes SheetCraft work is the tight marriage of two-stage supervised fine-tuning (SFT) (using LoRA on a Qwen3.6-27B base) and a budgeted multi-turn execution loop:

  1. Staged Training:
  2. Stage 1 (Tool Knowledge): Trains on single-turn Q&A pairs so the model learns API signatures, argument constraints, and component dependencies.
  3. Stage 2 (Feedback-Conditioned Repair): Trains on multi-turn agent trajectories—crucially keeping failed attempts alongside their compiler/runtime diagnostics and subsequent fixes. This teaches the model how to debug, not just how to write code.
  4. Budgeted Inference Loop: Each multi-turn case shares a strict budget of up to 20 compile/execute attempts. At each turn, code must pass a TypeScript Compile Gate, a sandbox Execute Gate, and a lightweight Supervisor Gate. If anything breaks, error logs are fed back into the prompt for targeted repair.
  5. Artifact-Grounded Evaluation: Rather than grading the code's text, SheetCraft exports the final, mutated spreadsheet state, strips away transient IDs and ordering noise (canonicalization), and uses an official judge to compare the actual resulting tables, dashboards, and permissions against a hidden reference artifact.

Datasets

All data originate from real-world user spreadsheet-construction scenarios, scrubbed of sensitive PII (names, emails, tokens) via the OpenAI Privacy Filter and accuracy-filtered to ensure clean execution paths:

  • SFT QA Stream: 31,997 operation-level examples (across 652 cases) distilled from GPT-5.5-Pro and GLM-5.1 to teach basic SDK semantics.
  • SFT Trajectory Stream: 10,059 multi-turn code-and-repair trajectories (across 205 cases) distilled from the same two teacher models.
  • Held-out Evaluation Benchmark: A newly curated test set of 595 real-scenario cases spanning 1,750 user turns, stratified to preserve realistic single- and multi-turn complexity. Unlike static table benchmarks, it evaluates multi-component state transitions across tables, views, dashboards, workflows, and permissions.

Key Insights and Ideas

  • Knowing the API isn't enough—you have to teach the crash recovery. An ablation study showed that training only on API documentation Q&A resulted in a dismal 17.6% first-try case execution rate (72.3% at 10 attempts). Adding multi-turn repair trajectories skyrocketed 10-attempt execution success to 95.0%.
  • SheetCraft shines on the rebound. On the very first attempt (Pass@1), giant frontier models like GPT-5.5-Pro write slightly cleaner code out of the gate. Give SheetCraft 5 to 10 repair attempts, however, and it overtakes every baseline—proving trajectory supervision genuinely internalizes diagnostic debugging.
  • Teacher diversity compounds repair skills. Distilling trajectories from both GPT-5.5-Pro and GLM-5.1 outperformed training on either teacher alone, particularly at higher retry budgets (Pass@5 and Pass@10), exposing the student to a wider variety of failure modes and recovery strategies.
Figure 4: Visualization of a representative four-turn inference trajectory. The selected case successfully passes compilation and execution across all turns; the final workflow turn requires one repair attempt before producing the accepted spreadsheet artifact.

Key Results

Evaluated on the 595-case (1,750-turn) benchmark against five frontier baselines (GPT-5.5, GPT-5.5-Pro, GLM-5.1, DeepSeek-V4-Pro, and Kimi-K2.5):

  • Execution Reliability: SheetCraft-27B achieved 96.6% compile / 95.0% execute success across entire multi-turn cases (565/595 cases), and 98.9% / 98.3% at the individual turn level—edging out GPT-5.5-Pro (94.8% case execute) and GLM-5.1 (93.3%).
  • Artifact Correctness: On strict end-state artifact judging, SheetCraft-27B took first place overall at 63.1% (vs. GPT-5.5-Pro's 62.9% and GPT-5.5's 56.1%), leading specifically in tricky, state-dependent Dashboard (79.0%) and Permission (85.0%) setups.
  • Massive Cost Efficiency Proxy: While top proprietary baselines like GPT-5.5-Pro cost upwards of $105 per million blended tokens (yielding just 0.90 execution points per dollar), SheetCraft achieves top-tier accuracy in a self-hostable 27B footprint averaging ~310 seconds per multi-turn case.

Limitations and Future Work

  • Domain & Ecosystem Scope: The 595-case benchmark skews toward business-oriented operational artifacts within a specific TypeScript SDK ecosystem; it doesn't yet cover all spreadsheet platforms, niche domain formulas, or multilingual instructions.
  • Infrastructure Fragility: Relying on live sandbox cloning and execution means evaluations are vulnerable to external service hiccups, authentication issues, or transient network timeouts.
  • Blind Spots in Aesthetic Judging: Normalized structural diffs verify data and config accuracy well, but can't judge visual layout appeal, UI ergonomics, or ambiguous business intent.
  • Long-Horizon Context Bloat: Multi-turn repair logs pile up fast, driving up latency and threatening the 128K context ceiling. The authors point to state abstraction, history summarization, and smarter long-horizon recovery policies as the next frontier.

Summary updated

BibTeX
@misc{zhang2026sheetcraft,
  author = {Zuowei Zhang and Xiaotian Li and Siyuan Li and Enhao Gu and Kexu Cheng and Hanbo Song and Yule Zhang},
  title = {{SheetCraft: Fine-Tuning Code Agents for Execution-Guided Spreadsheet Reasoning and Construction}},
  year = {2026},
  eprint = {2611.40353},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.40353},
}
Figure