Skip to main content

Code Execution Extension

The Code Execution extension enables Code Mode, a programmatic approach for interacting with MCP tools.

In Code Mode, the LLM discovers which tools are available from your enabled extensions and writes JavaScript code that goose runs in one execution instead of calling tools directly and one at a time. This helps manage context window usage more efficiently when multiple extensions are enabled and when performing workflows with multiple tool calls.

Configuration

Platform Extension

This is a built-in platform extension. Platform extensions provide core functionality and are used within goose just like MCP server extensions.

  1. Click the button in the top-left to open the sidebar
  2. Click Extensions in the sidebar
  3. Toggle Code Execution on

Example Usage

In this example, we'll ask goose to compile a report that requires multiple tool calls.

goose Prompt

Create a LOG.md file with the current git branch, last 3 commits, and the version from package.json

goose Output

Desktop

I'll help you create a LOG.md file with the git branch, last 3 commits, and version from package.json. Let me gather all this information in one operation.

Execute Code code: import { shell, text_editor } from "developer" ...

Let me check the package.json path first:

Execute Code code: import { shell, text_editor } from "developer" ...

Perfect! I've created the LOG.md file with:

  • Current git branch
  • Last 3 commits (with hash, message, author, and relative time)
  • Version from ui/desktop/package.json

The file has been saved to the root directory as LOG.md.