https://github.com/code-yeongyu/pi-anthropic-code-execution
Anthropic native code execution policy extension for the pi coding agent. Ensures native code_execution tools are present on anthropic-messages payloads when opt-in is enabled and appends code execution guidance to the system prompt.
https://github.com/code-yeongyu/pi-anthropic-code-execution
anthropic claude code-execution coding-agent pi pi-coding-agent pi-extension pi-mono typescript
Last synced: 23 days ago
JSON representation
Anthropic native code execution policy extension for the pi coding agent. Ensures native code_execution tools are present on anthropic-messages payloads when opt-in is enabled and appends code execution guidance to the system prompt.
- Host: GitHub
- URL: https://github.com/code-yeongyu/pi-anthropic-code-execution
- Owner: code-yeongyu
- License: mit
- Created: 2026-05-12T04:08:27.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-12T04:14:41.000Z (about 1 month ago)
- Last Synced: 2026-05-12T06:23:58.884Z (about 1 month ago)
- Topics: anthropic, claude, code-execution, coding-agent, pi, pi-coding-agent, pi-extension, pi-mono, typescript
- Language: TypeScript
- Size: 45.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Notice: NOTICE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-pi-coding-agent - code-yeongyu-pi-anthropic-code-execution - messages payloads when opt-in is enabled and appends code executi | | ~1mo ago | (Extensions)
README
# pi-anthropic-code-execution
[](https://github.com/code-yeongyu/pi-anthropic-code-execution/actions/workflows/ci.yml) [](LICENSE)
Anthropic native code execution extension for the [pi coding agent](https://github.com/badlogic/pi-mono/tree/main/packages/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.
| Case | Result |
|------|--------|
| `PI_ANTHROPIC_CODE_EXECUTION` is enabled, API is `anthropic-messages`, and no native `code_execution_*` tool exists | injects `{ type: "code_execution_20250825", name: "code_execution" }` |
| `PI_ANTHROPIC_CODE_EXECUTION` is enabled and a native `code_execution_*` tool already exists | preserves existing native tool (no duplication) |
| `PI_ANTHROPIC_CODE_EXECUTION` is enabled and a function variant named `code_execution` is present | strips function variant and keeps/uses native variant |
| `PI_ANTHROPIC_CODE_EXECUTION` is disabled or unset | no-op |
| API is non-Anthropic | no-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`](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent) coding agent. Pi loads extensions from `~/.pi/agent/extensions/`, project `.pi/extensions/`, or via the `--extension` / `-e` CLI flag.
```bash
# 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
```bash
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](LICENSE).
## Related
- [senpi](https://github.com/code-yeongyu/senpi) — the fork/runtime these extensions are extracted from.
- [Ultraworkers Discord](https://discord.gg/PUwSMR9XNk) — community link from the senpi README.
- [Dori](https://sisyphuslabs.ai) — the product powered by senpi under the hood.