From 1512d4c5a226f8f005d20c436a98e9c4215a13a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 26 Nov 2025 13:40:18 +0000 Subject: [PATCH] Update Code Interpreter docs for improved context isolation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Documents the fix for code context isolation bug where contexts leaked state after 10 executions. Each context now has dedicated executor resources throughout its lifetime, ensuring complete isolation. Changes: - Add context isolation note explaining dedicated resources - Emphasize isolation guarantees in createCodeContext() - Add cleanup best practice for deleteCodeContext() - Remove implied pool size limitations Related to cloudflare/sandbox-sdk#249 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/content/docs/sandbox/api/interpreter.mdx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/content/docs/sandbox/api/interpreter.mdx b/src/content/docs/sandbox/api/interpreter.mdx index 562effd32142ed..8f43a40c4f773a 100644 --- a/src/content/docs/sandbox/api/interpreter.mdx +++ b/src/content/docs/sandbox/api/interpreter.mdx @@ -9,11 +9,15 @@ import { TypeScriptExample } from "~/components"; Execute Python, JavaScript, and TypeScript code with support for data visualizations, tables, and rich output formats. Contexts maintain state (variables, imports, functions) across executions. +:::note[Context Isolation] +Each code context is fully isolated with dedicated execution resources from creation to deletion. Contexts do not share state with each other, ensuring complete isolation for security and correctness. You can create as many concurrent contexts as needed without pool size limitations. +::: + ## Methods ### `createCodeContext()` -Create a persistent execution context for running code. +Create a persistent execution context for running code. Each context receives dedicated execution resources and maintains complete isolation from other contexts. ```ts const context = await sandbox.createCodeContext(options?: CreateContextOptions): Promise @@ -121,7 +125,7 @@ console.log(`Found ${contexts.length} contexts`); ### `deleteCodeContext()` -Delete a code execution context and free its resources. +Delete a code execution context and free its dedicated execution resources. ```ts await sandbox.deleteCodeContext(contextId: string): Promise @@ -135,6 +139,10 @@ await sandbox.deleteCodeContext(ctx.id); ``` +:::caution[Context Cleanup] +Always delete contexts when finished to free resources. Each context maintains dedicated execution resources throughout its lifetime. +::: + ## Rich Output Formats Results include: `text`, `html`, `png`, `jpeg`, `svg`, `latex`, `markdown`, `json`, `chart`, `data`