#1639

Add an experimental execute tool for code mode

Draftfazxeswants to merge intofrom

Summary

  • Offer the model an execute tool when the experimental.code_mode setting is on. It runs a short JavaScript program in the sandboxed child. The setting is off by default and profile-only: fx config set experimental.code_mode true, or fx ask --config experimental.code_mode=true for one run.
  • Run each await tools.<name>(args) call a program makes like a direct call: validation, permission admission, and authorized execution. Any tool name works, including an MCP tool the model hasn't loaded.
  • In auto mode, review each call a program makes on its own, with the program's earlier results as evidence, sharing the turn's review budget and holds.
  • Return only the program's value, its console output, and a list of its tool calls to the model.
  • Refuse execute, ask_user_question, and subagent inside a program. A program gets 30 s of JavaScript time, which excludes time spent in tool calls, 64 MiB of heap, and at most 256 tool calls.
  • Never offer execute in libfx.

Docs

  • Settings reference: add experimental.code_mode (boolean, default false, profile only). It offers the execute tool, which runs a JavaScript program that calls the model's tools in a sandbox, on macOS and on Linux x86_64 and arm64.

Stacked on #1638.

Activity

6

This pull request is a draft

Merging is unavailable until it is marked ready for review.