Turing code mode
Analyze tool results with Python in a temporary offline sandbox.
Turing can use run_code to analyze data with Python. It can query VegaDB into a pandas DataFrame, combine results from tools it has already activated, and create downloadable conversation files. The answer receives captured text and file metadata.
Attachments and conversation files
A question accepts up to 10 attachments, each at most 25 MiB: PNG, JPEG, WebP, GIF, PDF, CSV, XLSX, JSON, TXT or Markdown. File names, types and contents are checked before the question starts. Unused uploads expire after 24 hours.
Profiles with multimodal input can receive images and PDFs directly, subject to provider limits and a bounded inline-media budget. Other files receive short previews: text and data previews cover at most 4 KiB or 50 lines; workbook previews cover the first rows of up to five sheets. When a file cannot be sent directly, Turing receives a note that it is available through code mode.
Both run_code and run_skill_script read conversation files from the read-only /input directory. A conversation in a project also reads the project's shared files from the read-only /project directory. Each call receives the project's files first, then the newest conversation files, within 50 files and 256 MiB in total; its result lists omitted files.
Write files to /output to keep them in the conversation. Up to 20 regular files and 128 MiB are kept per call. Directories and links are refused. Files are kept after success or a Python exception; timeout and memory failures discard them. The result lists any dropped files and the reason. Kept files appear as downloadable file cards and are available under /input in later calls. A conversation holds at most 100 files and 2 GiB, retained for the conversation's retention period.
Downloads use short-lived links and attachment disposition. Image previews are available for PNG, JPEG, WebP and GIF. Attachment content and untrusted tool output retain their trust labels, including when read again through /input.
Code runs in a fresh offline sandbox for each call. It has Python 3.13, pandas, PyArrow, Polars, DuckDB and NumPy. Top-level await and asyncio.gather are supported; tool requests are processed one at a time.
Tools and permissions
The generated vega module contains async functions for the run's active tools. Deferred tools must be activated with tool_search first. Functions accept keyword arguments from each tool's input schema. Stub names are readable lowercase Python identifiers, such as vegadb_query or github_issues_list. The code tool's description lists the active names and required arguments. Use await vega.call(tool_id, **arguments) to call an exact active tool ID. Child failures raise vega.ToolError with the tool's error code and a bounded message.
Every tool request uses the same user permissions, agent grants, policy, data classification and audit as a direct tool call. Reading untrusted or sensitive data in code carries those labels into the run. A later external write can therefore require approval even in auto mode.
Code can invoke READ and DRAFT tools. WRITE and DESTRUCTIVE functions raise vega.ApprovalRequired without executing anything or opening an approval. The error names the function, the tool's display name and its exact ID. Turing must call those tools directly to use the normal approval flow. A tool that needs connection selection or reconnection must also be called directly.
Querying VegaDB
import vega
df = await vega.query("SELECT category, amount FROM vegadb.public.sales")
print(df.groupby("category")["amount"].sum())Queries are read-only and return a pandas DataFrame through Arrow. Code-mode queries return at most 100,000 rows and 64 MiB by default; max_rows can request a smaller result. Ordinary model-facing query calls retain their existing 200-row ceiling.
Decimal columns remain Arrow decimals containing Python Decimal values. df.select_dtypes('number') may omit them. To use floating-point arithmetic, convert explicitly, for example df['amount_aed'] = df['amount_aed'].astype('float64'); keep decimals when exact arithmetic matters.
For a downloadable result, use vegadb.export_query directly or its code-mode stub:
import vega
result = await vega.vegadb_export_query(
sql="SELECT category, amount FROM vegadb.public.sales",
format="csv",
name="sales.csv",
)
print(result)Exports support CSV and Parquet, up to 1 GiB and the remaining conversation quota. They return the file name, row count, byte size and columns instead of placing the data in the model's context. CSV uses \N for NULL values and base64 for binary values. Exports use the same read-only SQL restrictions and user permissions as vegadb.query.
Limits and lifetime
The code's wall clock starts when the jail starts executing and pauses while it waits for a child tool, including a starting warehouse. Sandbox startup has its own bounded readiness budget. Signed execution authority expires within 15 minutes, and the run deadline remains a hard limit. If startup times out, the tool explains that the code did not run and can be retried shortly. If the sandbox is unavailable, the tool also returns a retryable error.
Each call defaults to 60 seconds of wall and CPU time, 2 GiB of address space, 256 MiB of temporary files, 64 KiB of source and model-visible output, an 8 KiB stderr tail on failure, and 50 nested tool requests. The run's existing tool budget also applies. Output above its ceiling receives a truncation marker. Python exceptions, memory exhaustion, timeouts and refused tool requests are tool errors; the agent can continue the run.
Only files kept from /output persist. Variables, temporary files and installed packages do not carry between calls. Network access, package installation and subprocess creation are unavailable.
Custom agent definitions opt in with "tools": {"code": {"enabled": true}}. Optional limits fields may only lower the defaults: wall_seconds, memory_mib, tmp_mib, source_bytes, output_bytes, stderr_bytes, nested_calls, query_rows and query_bytes.
Code mode is offered only when the workspace's compute policy and runtime provide an enabled VM-isolated Python sandbox, or the definition uses suitable dedicated compute. New Turing conversations use the updated built-in definition; existing conversations retain their pinned definition version. Code mode is excluded from Turing's inbound MCP tool catalog.
Turing conversations and projects
Find conversations, follow question events, organize personal projects, and manage reusable instructions through the Turing API.
Custom agents API
Author workspace agents, publish versions, chat with them, start runs from the API, on a schedule or from other agents, and review runs, policies and decisions.