# Teaching AI Agents to Master Spreadsheets _Nuno Campos of Witan Labs discusses teaching AI agents to master spreadsheets using a REPL approach, improving accuracy and efficiency._ **Updated:** 2026-08-22 **Published:** 2026-07-08 **Source:** https://www.startuphub.ai/ai-news/artificial-intelligence/2026/teaching-ai-agents-to-master-spreadsheets --- Nuno Campos, CTO & Co-Founder of Witan Labs, delivered a compelling presentation on "Teaching Coding Agents to do Spreadsheets" at AI Engineer Europe. Campos shared insights from Witan Labs' efforts to improve [AI agent capabilities](/ai-news/artificial-intelligence/2026/ai-agents-don-t-always-follow-rules) in handling spreadsheet data, a task that presents unique challenges compared to traditional code execution. Witan Labs' approachCoreFocus on structured interaction for AI spreadsheet masteryFrom the article 3 mentionsThe Witan Labs team iterated on their approach, changing tools four times over four months, yet found that "domain knowledge improved results on every one of them." This underscored the critical role of understanding the specific domain, in this case, financial analysis, in guiding the AI's interactions with the spreadsheet.addressesAI struggles with spreadsheetsDriverLLMs see spreadsheets as flat data, not structured tablesFrom the article 9+ mentionsNuno Campos, CTO & Co-Founder of Witan Labs, delivered a compelling presentation on "Teaching Coding Agents to do Spreadsheets" at AI Engineer Europe.solved byHuman vs AI perceptionContextHumans grasp tables/summaries, AI lacks inherent structural understandingFrom the article 2 mentionsCampos highlighted the fundamental difference in how humans and AI agents perceive spreadsheets.REPL solutionCoreInteractive execution environment for AI agentsFrom the article 5 mentionsA significant breakthrough came with the adoption of a persistent Node.js REPL (Read-Eval-Print Loop) combined with a spreadsheet API.leads toImproved accuracyEffectREPL enables better calculation and data identificationFrom the article 2 mentionsThis not only simplified the agent's workflow but also improved its ability to reason about the interdependencies between different parts of the spreadsheet.Increased efficiencyEffectFaster and more reliable spreadsheet task completionGeneralizable lessonsOutcomeInsights for teaching AI agents complex data tasksFrom the articleThe insights gained from this process, particularly the value of REPLs and domain knowledge, offer valuable lessons for the broader AI development community. ## The Spreadsheet Challenge for AI Agents Campos highlighted the fundamental difference in how humans and AI agents perceive spreadsheets. While humans can intuitively grasp tables, assumptions, and P&L summaries, Large Language Models (LLMs) initially process spreadsheets as a flat collection of cell values and formatting metadata. This lack of inherent structural understanding makes tasks like calculating revenue or identifying specific data points within a large spreadsheet a significant hurdle for AI agents. The presentation detailed the journey of improving an AI agent's spreadsheet proficiency, which involved overcoming numerous challenges and "dead ends." Early attempts focused on breaking down the task into multiple specialized agents, each handling a specific function like block discovery, editing, or answering questions. However, Campos noted that these rigid architectures often proved insufficient. A key finding was that **"rigid architectures don't win."** ## The REPL Solution and its Advantages A significant breakthrough came with the adoption of a persistent Node.js REPL (Read-Eval-Print Loop) combined with a spreadsheet API. This approach fundamentally changed how the agent interacted with spreadsheets. Instead of making numerous discrete tool calls, the agent could now write and execute JavaScript code within the REPL. This allowed for **"persistent state,"** meaning variables and workbook states could be maintained across calls, enabling the agent to build understanding incrementally. Campos illustrated the difference with a 'Before vs. After' code example. Previously, an agent might require 10-15 tool calls to extract basic information, such as listing sheets, reading a range, finding cells, and reading a specific cell's value. With the REPL approach, these operations could be consolidated into a single, more coherent code execution. This not only simplified the agent's workflow but also improved its ability to reason about the interdependencies between different parts of the spreadsheet. ## Lessons Learned and Generalizations The Witan Labs team iterated on their approach, changing tools four times over four months, yet found that **"domain knowledge improved results on every one of them."** This underscored the critical role of understanding the specific domain, in this case, financial analysis, in guiding the AI's interactions with the spreadsheet. The presentation outlined several key takeaways that generalize beyond spreadsheet tasks: - Many small sequential tool calls are less effective than a single, well-crafted scripting language command. - Building verification engines, including formula calculation, rendering, and linting, creates a feedback loop that leverages model capabilities rather than merely replacing them. - Interfaces, while potentially ephemeral, are less critical than the underlying "engines" that perform the core tasks. The REPL, in this context, serves as a powerful interface because coding is a strong suit for current AI models. - Structured reasoning, which involves defining the end state and planning before execution, tends to be more effective than purely tool-based approaches. - Domain knowledge is paramount and often outweighs the specific choice of tools. - Evaluation should be matched to the output type: deterministic comparison for objective data and LLM grading for subjective text. - When an agent appears confused, checking the underlying infrastructure or "plumbing" is often the first step to diagnosing the problem, as apparent reasoning failures can stem from infrastructure bugs. Campos concluded by emphasizing that 568 commits were made to develop the agent and its supporting infrastructure, highlighting the complexity involved in creating robust AI agents for specialized tasks. The insights gained from this process, particularly the value of REPLs and domain knowledge, offer valuable lessons for the broader AI development community. --- Original analysis from [startuphub.ai](https://www.startuphub.ai), the #1 AI startup directory. © StartupHub.ai. All rights reserved. You may not republish this article in full without a license. Search engines and AI research tools may crawl and summarize for reference. Bulk reproduction or model training on this content requires a license. See https://www.startuphub.ai/terms.