pi-anthropic-code-execution

May 12, 2026 · View on GitHub

ci license: MIT

Anthropic native code execution extension for the pi coding agent.

This package is the standalone extraction of senpi's former builtin anthropic-code-execution extension.

Behavior

The extension does not register a new tool. It intercepts Anthropic requests before they are sent and ensures a native code_execution_* tool is present for anthropic-messages payloads only when code execution is explicitly enabled.

CaseResult
PI_ANTHROPIC_CODE_EXECUTION is enabled, API is anthropic-messages, and no native code_execution_* tool existsinjects { type: "code_execution_20250825", name: "code_execution" }
PI_ANTHROPIC_CODE_EXECUTION is enabled and a native code_execution_* tool already existspreserves existing native tool (no duplication)
PI_ANTHROPIC_CODE_EXECUTION is enabled and a function variant named code_execution is presentstrips function variant and keeps/uses native variant
PI_ANTHROPIC_CODE_EXECUTION is disabled or unsetno-op
API is non-Anthropicno-op

Truthy values for PI_ANTHROPIC_CODE_EXECUTION are: 1, true, yes, on (case-insensitive, surrounding whitespace allowed).

It also appends a system-prompt section for Anthropic sessions indicating native code_execution availability when enabled.

Installation

The package targets the pi coding agent. Pi loads extensions from ~/.pi/agent/extensions/, project .pi/extensions/, or via the --extension / -e CLI flag.

# From npm (once published)
pi install npm:pi-anthropic-code-execution

# From git
pi install git:github.com/code-yeongyu/pi-anthropic-code-execution

# Manual placement
git clone https://github.com/code-yeongyu/pi-anthropic-code-execution ~/.pi/agent/extensions/pi-anthropic-code-execution
cd ~/.pi/agent/extensions/pi-anthropic-code-execution && npm install

# Dev / one-shot test
pi -e /path/to/pi-anthropic-code-execution/src/index.ts

After installation, restart pi or run /reload inside an interactive session.

Development

npm install
npm test
npm run typecheck
npm run check
pi -e ./src/index.ts

The test suite uses vitest. TypeScript is strict, Node-only, and uses ESM imports with .js suffixes.

Origin

Ported from packages/coding-agent/src/core/extensions/builtin/anthropic-code-execution/index.ts in code-yeongyu/senpi-mono.

License

MIT.

  • senpi — the fork/runtime these extensions are extracted from.
  • Ultraworkers Discord — community link from the senpi README.
  • Dori — the product powered by senpi under the hood.