Skip to content

Code Execution & Python Sandbox

Code Execution & Python Sandbox

AMC WebUI provides two distinct execution engines for computation, data analysis, and mathematical verification.


Engine Comparison

Feature☁️ Gemini Code Execution🐍 Local Pyodide WASM Sandbox
Execution HostGoogle Cloud stateless containerBrowser Web Worker (WebAssembly)
Data PrivacySent to Google for processing100% Local, zero network leaks
Preloaded LibrariesStandard Google runtimenumpy, pandas, matplotlib
Dynamic PackagesFixed environmentDynamic installation (scipy, scikit-learn)
File I/OAttachment analysis on serverVirtual filesystem mounting & file export
Plot RenderingText output or static imagesAutomatic matplotlib plot interception

1. Server-Side Code Execution

  • Toggle: Select Code Execution in the tools menu, or type /code.
  • Workflow: The model writes and executes Python in Google’s cloud runtime. Real stdout/stderr output is injected back into the conversation for self-correcting logic.

2. Browser-Side Local Python Sandbox (Pyodide)

A standalone Python environment running entirely client-side:

  1. Independent Worker: Runs inside an isolated Web Worker to avoid blocking UI interactions.
  2. Matplotlib Visualizer: Automatically catches plt.show() canvas outputs and embeds responsive graphs directly in the message flow.
  3. Virtual File System: Uploaded CSV/Excel files mount to /workspace/, enabling direct manipulation via pandas.read_csv().