GA Release

The Multi-Agent WebGPU Engine & Interactions API are now generally available.

Part 10: Python Playground — WASM Python, Plots & Data Analysis

Run client-side Python in WebAssembly with Pyodide, render Matplotlib plots, perform Pandas data analysis, and execute background AI code verification.

Category: Getting Started • Read Time: 21 min read • Updated: August 2026

1. What is this, Really?

The Python Playground is a full Python 3 interpreter running inside your browser tab via WebAssembly (Pyodide). Code never leaves your device and requires no backend server.

100% Client-Side WASM Execution

Pyodide downloads the initial runtime (~6-10MB) on first launch. You can process algorithms, analyze CSV data with Pandas, compute matrix algebra with NumPy, and render Matplotlib charts directly in-browser.

2. Opening the Python Playground

Standalone Playground Modal

Launch via Sidebar → Experimental → Python Sandbox. Features a project selector, code editor, stdout terminal console, and dedicated PNG plot preview pane.

Automated Chat Agent Execution

When AI agents emit <python_tool> blocks, code executes silently in a background web worker and streams stdout into thinking traces.

3. Running Your First Script

Write standard Python code in the editor and click Run Python Code. The console displays web worker initialization logs, auto-installed packages, formatted stdout output, and detailed tracebacks for syntax errors.

4. Supported Packages & WASM Capabilities

✅ Supported & Pre-Loaded
  • numpy (matrix algebra & math)
  • pandas (DataFrames & CSV parsing)
  • matplotlib (charts & visual plots)
  • micropip (in-browser package installer)
⚠️ WASM Sandbox Limitations
  • No direct local file system access (paste CSVs as strings)
  • No arbitrary HTTP networking inside WASM
  • GUI windows like Tkinter or Pygame windows are shimmed

5. Plotting — Matplotlib Visual Outputs

When your code invokes plt.show(), Pyodide captures the Agg render buffer as a base64 PNG image and displays it directly inside the Plot Output pane.

# Data analysis & plotting snippet pattern:

import pandas as pd

import matplotlib.pyplot as plt

import io

df = pd.read_csv(io.StringIO(csv_data))

plt.bar(df['name'], df['sales'])

plt.show()

6. Projects & Local Persistence

Python Playground scripts automatically persist as Python Projects in browser local storage. When Google Drive backup is active with Projects enabled, Python scripts automatically synchronize to cloud storage in my_ai_projects.json.

7. Two-Way Integration with Chat & Agents

Agent Background Verification: When you ask the chat agent to verify mathematical calculations or analyze a CSV, the Lead Developer agent uses the background WASM worker to run code before formulating its answer.

Playground to Chat: Draft data scripts in the playground, then copy and attach them to chat prompts for AI refinement or UI integration.

8. Timeout Limits & Error Safety

20-Second Worker Timeout: Infinite loops or oversized computations trigger an automatic 20-second worker termination to protect system memory.

Explicit Print Statements: Always use explicit print() calls to ensure values display in the stdout console drawer.

9. Tool Selection: Python Sandbox vs Web Sandbox vs Chat Tool

Python Playground

Ideal for data exploration, Pandas analysis, static Matplotlib charts, and offline algorithm testing.

Web Sandbox

Ideal for web UI apps, interactive React dashboards, Tailwind layouts, and full-stack web previews.

Chat Python Tool

Automated background execution used by AI agents to verify math or data logic before giving final answers.