The Deska blog
Running Agents on Jupyter Notebooks
A technical guide on running agents on Jupyter Notebooks to automate data analysis, visualization, and code generation within a local developer environment.
10 min read
Modern data science and research workflows are evolving beyond manual cell execution. The practice of running agents on Jupyter Notebooks allows developers to automate complex exploratory data analysis, generate visualizations, and refactor messy experimental code through natural language interfaces. Rather than treating the notebook as a static document, integrating AI agents transforms it into an active execution environment where the agent can observe outputs, correct errors, and iterate on logic autonomously.
The Architecture of Agentic Notebooks
To understand how agents interact with notebooks, one must look at the underlying Jupyter architecture. A notebook is essentially a JSON document that communicates with a kernel through the ZeroMQ protocol. When you are running agents on Jupyter Notebooks, the agent typically operates in one of two ways.
First, the agent can act as a wrapper around the IPython kernel. In this model, the agent receives a high level goal, generates the Python code required to achieve it, and sends that code to the kernel. It then parses the stdout, stderr, and rich media outputs (like plots) to decide if the step was successful. If the code fails, the agent uses the traceback to self correct.
Second, the agent can exist as an external entity with filesystem access. This is common with CLI based agents that treat the .ipynb file as a target for modification. This approach is often more robust for large scale refactoring or migrating notebook logic into production ready Python scripts.
Core Capabilities of AI Agents in Data Science
Running agents on Jupyter Notebooks provides several immediate benefits for technical workflows. These agents are not merely autocomplete engines; they are goal oriented entities capable of managing long running tasks.
- Automated Data Cleaning: Agents can inspect a DataFrame, identify missing values or outliers, and write the necessary boilerplate code to handle them.
- Visualization Generation: Instead of looking up Matplotlib or Plotly syntax, you can describe the desired insight. The agent generates the plot and adjusts aesthetics based on the data distribution.
- Documentation and Annotation: Agents can analyze a series of experimental cells and generate Markdown headers or explanations to make the notebook readable for other team members.
- Library Migration: If you need to move a project from Pandas to Polars for performance, an agent can rewrite the logic across dozens of cells while maintaining the original intent.
Comparing Approaches to Agent Integration
Different tools take unique approaches to how they provide these agentic capabilities. The right choice depends on your privacy requirements and your preferred interface.
| Tool Category | Primary Interface | Execution Model |
|---|---|---|
| Integrated IDEs | Chat Sidebar | Internal Kernel Access |
| CLI Agents | Terminal | Filesystem Access |
| Canvas Workspaces | Infinite Canvas | Side by Side Execution |
| Web Notebooks | Browser | Cloud Managed |
Standard IDEs often provide a chat interface that can see your code but might struggle with the non linear nature of notebooks. CLI agents like Claude Code or Codex CLI provide powerful terminal based interactions that can execute commands and modify files directly. These tools differ in approach compared to cloud based solutions that manage the infrastructure for you but might require uploading sensitive datasets to their servers.
Integrating Deska into the Workflow
For developers who prefer to keep their data on their own hardware, Deska provides a unique environment for running agents on Jupyter Notebooks. The application operates as a free desktop app for Mac, Windows, and Linux, focusing on a local-first philosophy.
In Deska, you can arrange your workflow using an infinite canvas. This allows you to place a Jupyter instance in one panel while running coding agents like Claude Code or OpenCode in adjacent terminal panels. This side by side arrangement is beneficial because you can see the agent's logic in the terminal while observing the notebook's visual output in real time.
If you are using the lifetime tier, you can bring your own API keys to interact with these models. The workspace also includes a feature called Ask Deska, a voice and chat assistant that can drive the environment. It can open specific panels or run commands, allowing you to manage the workspace while the agent focuses on the code.
Privacy and Local Execution
A significant concern when running agents on Jupyter Notebooks is the security of the data being analyzed. Many data science projects involve proprietary information or sensitive PII. Using a local-first tool ensures that your code, files, and notebook sessions stay on your machine.
Deska facilitates this by ensuring that the workspace itself is local. Even when you use the mobile app to monitor a long running training session, the devices pair directly through a secure relay. No ports are exposed to the public internet, and the data does not live on a third party server. This is a critical consideration for researchers who must comply with strict data residency requirements.
Troubleshooting Agentic Notebooks
When you start running agents on Jupyter Notebooks, you may encounter specific challenges related to state management. Notebooks are notorious for out of order execution, which can confuse an agent that expects a linear flow.
- Reset the Kernel: If the agent is getting confused by old variables, use a fresh kernel session to ensure a clean state.
- Limit Context: Providing a 100 cell notebook to an agent can lead to token exhaustion or hallucinations. Break large notebooks into smaller, functional units.
- Verify Imports: Agents sometimes assume libraries are installed. Ensure your environment matches the agent's assumptions by running a
pip freezein a terminal panel.
FAQ
How to use Claude Code with Jupyter?
To use Claude Code with Jupyter, you should run the agent in a terminal within the same directory as your .ipynb files. The agent can then read the notebook content, suggest changes, or even execute python scripts that interact with the same data files used by your notebook.
Are AI agents safe for private data science?
Safety depends on the tool. If you use a local-first workspace and your own API keys, the data remains under your control. Always ensure that the agent is not configured to send your training data back for model improvements unless you have explicitly opted in.
Can AI agents run cells automatically?
Yes, some agentic frameworks are designed to interact with the Jupyter kernel directly. They send code blocks to the kernel, wait for the execution to finish, and then process the result. In a workspace like Deska, you can run these agents in panels alongside your notebook to monitor their progress.
Getting Started with Agentic Workspaces
Transitioning to an agentic workflow requires the right set of tools and a mindset shift toward automation. By combining the visual feedback of Jupyter with the reasoning capabilities of modern LLMs, you can significantly accelerate your development cycle.
To begin setting up your own local environment for running agents on Jupyter Notebooks, you can download the Deska desktop app. Once installed, check the getting started guide to learn how to configure your first workspace and connect your preferred coding agents.