🎫 Ticket 268: explore code mode (no milestone)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5faf85c parent: 03e1e42 added
.tickets/issues/0268-explore-code-mode-the-model-writes-a-script-that-calls-the-tools.yaml +114 -0 | new file mode 100644 | ||
| @@ -0,0 +1,114 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 268 | |
| 3 | +title: "Explore code mode: the model writes a script that calls the tools, run in a sandbox" | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-26T19:00:00.000Z | |
| 9 | +updatedAt: 2026-11-26T19:00:00.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | + - tools | |
| 14 | +epic: Ideas | |
| 15 | +related: | |
| 16 | + - 4 | |
| 17 | + - 46 | |
| 18 | +body: | | |
| 19 | + ## Asked (user, 2026-11-26) | |
| 20 | + Explore "code mode" for mm: instead of calling tools one at a time, the | |
| 21 | + model writes a short program that calls them, run in a sandbox. No | |
| 22 | + milestone: exploration first. | |
| 23 | + | |
| 24 | + ## What code mode is | |
| 25 | + - Cloudflare "Code Mode" (2025-09): MCP tools turned into a typed | |
| 26 | + TypeScript API; the model writes code against it, run in a V8 isolate | |
| 27 | + that can reach only those tools. Argument: models have seen far more | |
| 28 | + real code than tool-call JSON. | |
| 29 | + - Anthropic "Code execution with MCP" (2025-11): tools shown as files, | |
| 30 | + discovered on demand instead of every definition in the prompt; | |
| 31 | + intermediate results stay in the sandbox — the code filters, | |
| 32 | + aggregates, loops, and only the useful result goes back to the model. | |
| 33 | + - Docker MCP Gateway has a `code-mode` tool (combines gateway tools in | |
| 34 | + a sandboxed script) — details to check. | |
| 35 | + | |
| 36 | + ## Expected gains | |
| 37 | + - fewer tokens: fewer tool definitions in the prompt, big results do | |
| 38 | + not go through the model; | |
| 39 | + - fewer round trips: a loop or ten chained calls in one script; | |
| 40 | + - more reliable composition ("for each file call X, keep those where Y"). | |
| 41 | + | |
| 42 | + ## Costs and risks | |
| 43 | + - a real sandbox: isolation, no network or disk outside the tools, | |
| 44 | + time and memory limits; | |
| 45 | + - the model must write code well — small local models are less sure on | |
| 46 | + a script than on one tool call (to measure, not to assume); | |
| 47 | + - harder to debug; per-tool permissions end up inside a script. | |
| 48 | + | |
| 49 | + ## In mm today | |
| 50 | + No mention of code mode in the repository. `bash` comes close (the model | |
| 51 | + writes a script) but with no typed API for mm or MCP tools and no | |
| 52 | + dedicated sandbox. Leads: internal/mcp (MCP tools), declared tools, | |
| 53 | + internal/wasmtool (wazero, WASM tools), internal/consent (permissions). | |
| 54 | + | |
| 55 | + ## Open questions | |
| 56 | + - JS (goja) or a WASM interpreter (wazero)? | |
| 57 | + - one `run_code` tool beside the normal tools, or instead of them for | |
| 58 | + MCP servers marked for it? | |
| 59 | + - how does the struggle/loop detection see a script? | |
| 60 | +tasks: | |
| 61 | + - id: 1 | |
| 62 | + title: "State of the art: Cloudflare Code Mode, Anthropic code execution with MCP, Docker MCP Gateway code-mode — what each exposes, sandbox, results" | |
| 63 | + state: open | |
| 64 | + priority: medium | |
| 65 | + author: | |
| 66 | + name: k33g | |
| 67 | + email: ph.charriere@gmail.com | |
| 68 | + createdAt: 2026-11-26T19:00:00.000Z | |
| 69 | + updatedAt: 2026-11-26T19:00:00.000Z | |
| 70 | + - id: 2 | |
| 71 | + title: "Choose the runtime: goja (pure-Go JS) vs a JS/Python interpreter in WASM on wazero (already in go.mod) — isolation, limits, size, cross-compile" | |
| 72 | + state: open | |
| 73 | + priority: medium | |
| 74 | + author: | |
| 75 | + name: k33g | |
| 76 | + email: ph.charriere@gmail.com | |
| 77 | + createdAt: 2026-11-26T19:00:00.000Z | |
| 78 | + updatedAt: 2026-11-26T19:00:00.000Z | |
| 79 | + - id: 3 | |
| 80 | + title: "Prototype a run_code tool behind a switch: MCP + declared tools as typed functions, a short API listing in the description, stdout + return value as the result" | |
| 81 | + state: open | |
| 82 | + priority: medium | |
| 83 | + author: | |
| 84 | + name: k33g | |
| 85 | + email: ph.charriere@gmail.com | |
| 86 | + createdAt: 2026-11-26T19:00:00.000Z | |
| 87 | + updatedAt: 2026-11-26T19:00:00.000Z | |
| 88 | + - id: 4 | |
| 89 | + title: "Permissions: yolo false / MCP ask inside a script — ask per call through consent, or once per script?" | |
| 90 | + state: open | |
| 91 | + priority: medium | |
| 92 | + author: | |
| 93 | + name: k33g | |
| 94 | + email: ph.charriere@gmail.com | |
| 95 | + createdAt: 2026-11-26T19:00:00.000Z | |
| 96 | + updatedAt: 2026-11-26T19:00:00.000Z | |
| 97 | + - id: 5 | |
| 98 | + title: "Measure with a small local model (Qwen3.5 4B, gpt-oss 20B) on 3–4 tasks: tokens, model calls, success vs classic tool calls" | |
| 99 | + state: open | |
| 100 | + priority: medium | |
| 101 | + author: | |
| 102 | + name: k33g | |
| 103 | + email: ph.charriere@gmail.com | |
| 104 | + createdAt: 2026-11-26T19:00:00.000Z | |
| 105 | + updatedAt: 2026-11-26T19:00:00.000Z | |
| 106 | + - id: 6 | |
| 107 | + title: "Decide (with the user): keep, drop, or file the implementation ticket" | |
| 108 | + state: open | |
| 109 | + priority: medium | |
| 110 | + author: | |
| 111 | + name: k33g | |
| 112 | + email: ph.charriere@gmail.com | |
| 113 | + createdAt: 2026-11-26T19:00:00.000Z | |
| 114 | + updatedAt: 2026-11-26T19:00:00.000Z | |
| new file mode 100644 | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 268 | ||
| 3 | +title: "Explore code mode: the model writes a script that calls the tools, run in a sandbox" | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-26T19:00:00.000Z | ||
| 9 | +updatedAt: 2026-11-26T19:00:00.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | + - tools | ||
| 14 | +epic: Ideas | ||
| 15 | +related: | ||
| 16 | + - 4 | ||
| 17 | + - 46 | ||
| 18 | +body: | | ||
| 19 | + ## Asked (user, 2026-11-26) | ||
| 20 | + Explore "code mode" for mm: instead of calling tools one at a time, the | ||
| 21 | + model writes a short program that calls them, run in a sandbox. No | ||
| 22 | + milestone: exploration first. | ||
| 23 | + | ||
| 24 | + ## What code mode is | ||
| 25 | + - Cloudflare "Code Mode" (2025-09): MCP tools turned into a typed | ||
| 26 | + TypeScript API; the model writes code against it, run in a V8 isolate | ||
| 27 | + that can reach only those tools. Argument: models have seen far more | ||
| 28 | + real code than tool-call JSON. | ||
| 29 | + - Anthropic "Code execution with MCP" (2025-11): tools shown as files, | ||
| 30 | + discovered on demand instead of every definition in the prompt; | ||
| 31 | + intermediate results stay in the sandbox — the code filters, | ||
| 32 | + aggregates, loops, and only the useful result goes back to the model. | ||
| 33 | + - Docker MCP Gateway has a `code-mode` tool (combines gateway tools in | ||
| 34 | + a sandboxed script) — details to check. | ||
| 35 | + | ||
| 36 | + ## Expected gains | ||
| 37 | + - fewer tokens: fewer tool definitions in the prompt, big results do | ||
| 38 | + not go through the model; | ||
| 39 | + - fewer round trips: a loop or ten chained calls in one script; | ||
| 40 | + - more reliable composition ("for each file call X, keep those where Y"). | ||
| 41 | + | ||
| 42 | + ## Costs and risks | ||
| 43 | + - a real sandbox: isolation, no network or disk outside the tools, | ||
| 44 | + time and memory limits; | ||
| 45 | + - the model must write code well — small local models are less sure on | ||
| 46 | + a script than on one tool call (to measure, not to assume); | ||
| 47 | + - harder to debug; per-tool permissions end up inside a script. | ||
| 48 | + | ||
| 49 | + ## In mm today | ||
| 50 | + No mention of code mode in the repository. `bash` comes close (the model | ||
| 51 | + writes a script) but with no typed API for mm or MCP tools and no | ||
| 52 | + dedicated sandbox. Leads: internal/mcp (MCP tools), declared tools, | ||
| 53 | + internal/wasmtool (wazero, WASM tools), internal/consent (permissions). | ||
| 54 | + | ||
| 55 | + ## Open questions | ||
| 56 | + - JS (goja) or a WASM interpreter (wazero)? | ||
| 57 | + - one `run_code` tool beside the normal tools, or instead of them for | ||
| 58 | + MCP servers marked for it? | ||
| 59 | + - how does the struggle/loop detection see a script? | ||
| 60 | +tasks: | ||
| 61 | + - id: 1 | ||
| 62 | + title: "State of the art: Cloudflare Code Mode, Anthropic code execution with MCP, Docker MCP Gateway code-mode — what each exposes, sandbox, results" | ||
| 63 | + state: open | ||
| 64 | + priority: medium | ||
| 65 | + author: | ||
| 66 | + name: k33g | ||
| 67 | + email: ph.charriere@gmail.com | ||
| 68 | + createdAt: 2026-11-26T19:00:00.000Z | ||
| 69 | + updatedAt: 2026-11-26T19:00:00.000Z | ||
| 70 | + - id: 2 | ||
| 71 | + title: "Choose the runtime: goja (pure-Go JS) vs a JS/Python interpreter in WASM on wazero (already in go.mod) — isolation, limits, size, cross-compile" | ||
| 72 | + state: open | ||
| 73 | + priority: medium | ||
| 74 | + author: | ||
| 75 | + name: k33g | ||
| 76 | + email: ph.charriere@gmail.com | ||
| 77 | + createdAt: 2026-11-26T19:00:00.000Z | ||
| 78 | + updatedAt: 2026-11-26T19:00:00.000Z | ||
| 79 | + - id: 3 | ||
| 80 | + title: "Prototype a run_code tool behind a switch: MCP + declared tools as typed functions, a short API listing in the description, stdout + return value as the result" | ||
| 81 | + state: open | ||
| 82 | + priority: medium | ||
| 83 | + author: | ||
| 84 | + name: k33g | ||
| 85 | + email: ph.charriere@gmail.com | ||
| 86 | + createdAt: 2026-11-26T19:00:00.000Z | ||
| 87 | + updatedAt: 2026-11-26T19:00:00.000Z | ||
| 88 | + - id: 4 | ||
| 89 | + title: "Permissions: yolo false / MCP ask inside a script — ask per call through consent, or once per script?" | ||
| 90 | + state: open | ||
| 91 | + priority: medium | ||
| 92 | + author: | ||
| 93 | + name: k33g | ||
| 94 | + email: ph.charriere@gmail.com | ||
| 95 | + createdAt: 2026-11-26T19:00:00.000Z | ||
| 96 | + updatedAt: 2026-11-26T19:00:00.000Z | ||
| 97 | + - id: 5 | ||
| 98 | + title: "Measure with a small local model (Qwen3.5 4B, gpt-oss 20B) on 3–4 tasks: tokens, model calls, success vs classic tool calls" | ||
| 99 | + state: open | ||
| 100 | + priority: medium | ||
| 101 | + author: | ||
| 102 | + name: k33g | ||
| 103 | + email: ph.charriere@gmail.com | ||
| 104 | + createdAt: 2026-11-26T19:00:00.000Z | ||
| 105 | + updatedAt: 2026-11-26T19:00:00.000Z | ||
| 106 | + - id: 6 | ||
| 107 | + title: "Decide (with the user): keep, drop, or file the implementation ticket" | ||
| 108 | + state: open | ||
| 109 | + priority: medium | ||
| 110 | + author: | ||
| 111 | + name: k33g | ||
| 112 | + email: ph.charriere@gmail.com | ||
| 113 | + createdAt: 2026-11-26T19:00:00.000Z | ||
| 114 | + updatedAt: 2026-11-26T19:00:00.000Z | ||