Agent Extensions¶
Summary¶
TypeScript-based extension systems that allow coding agents to customize their behavior beyond what's possible with configuration files alone — adding tools, UI elements, event handlers, and deterministic workflows.
Pi's Extension System¶
Pi's extensions are TypeScript files placed in ~/.pi/agent/extensions/ that can:
- Customize the UI — Git status display, funny messages, branch info
- Register custom tools — New capabilities the agent can call
- Intercept tool calls — Modify behavior of existing tools
- Listen to events — React to agent actions, save state
- Custom compaction — Control how context is summarized
- Hot reload — See changes immediately during development
Example: Context Workflow Extension¶
A multi-step development pipeline encoded as an extension: 1. Read specification 2. Write implementation 3. Review code (fresh context window) 4. Fix issues 5. Run tests 6. Final verification
The agent manages its own state through workflow.next — a built-in tool for stepping through deterministic pipelines. Each step uses a fresh context window for code review.
Extensions vs. Hooks¶
| Claude Code Hooks | Pi Extensions | |
|---|---|---|
| Language | Any executable | TypeScript |
| Execution | Spawns new process per trigger | Loaded in-process |
| Depth | Shallow (limited trigger points) | Deep (full API access) |
| UI | None | Full customization |
| Hot reload | No | Yes |
Building Extensions¶
The recommended approach: use the agent itself to build extensions. The agent has access to its own documentation and source code, so it can write extensions for itself.