Pi Coding Agent - Language Model Provider for VS Code

VS Code Language Model Chat Provider integration for Mario Zechner's open source Pi coding agent, making Pi models available in VS Code's model picker for use with GitHub Copilot Chat and any extension that consumes the vscode.lm.* APIs.
https://github.com/user-attachments/assets/196cffa2-660e-4b7e-911b-389830420579
Features
- Universal Model Access: Use Pi with any VS Code extension that supports language models
- Dynamic Model Discovery: Automatically detects all configured models from Pi
- Tool Execution: Pi handles tools internally (file operations, bash commands, etc.)
- Streaming Responses: Real-time streaming of LLM responses
- Tool Transparency: Optional display of tool execution as text annotations
Prerequisites
Pi CLI must be installed and available in your PATH:
npm install -g @mariozechner/pi-coding-agent
API Keys configured via Pi:
pi> /login
Installation
- Install the extension from the VS Code Marketplace (or build from source)
- Verify Pi is installed:
pi --version
- Open VS Code and Pi models will appear in the model picker
Configuration
Access settings via Ctrl/Cmd+, and search for "Pi":
| Setting |
Description |
Default |
pi.binaryPath |
Path to Pi CLI binary |
pi |
pi.workingDirectory |
Working directory for Pi agent |
Workspace root |
pi.autoRestart |
Auto-restart on crash |
true |
pi.maxRestartAttempts |
Max restart attempts |
3 |
pi.additionalArgs |
Additional CLI arguments |
[] |
pi.debug |
Enable debug logging |
false |
Usage
With GitHub Copilot Chat
- Open Copilot Chat (
Ctrl/Cmd+Shift+I)
- Click the model picker
- Select a Pi model (e.g.,
pi:anthropic:claude-sonnet-4-20250514)
- Start chatting!
With Other Extensions
Any extension using vscode.lm.* APIs can use Pi models:
const models = await vscode.lm.selectChatModels({ vendor: 'pi' });
const model = models[0];
const response = await model.sendRequest(messages, {}, token);
Architecture
- Process Isolation: Pi runs in a separate process for stability
- RPC Communication: Uses Pi's RPC mode over stdin/stdout
- Fresh Sessions: Each request starts a fresh session (MVP)
- Tool Handling: Pi executes tools internally, only final text reaches VS Code
Troubleshooting
"Pi CLI not found"
Ensure Pi is installed and in your PATH:
which pi
# or
npm install -g @mariozechner/pi-coding-agent
Check Logs
Open the Output panel (Ctrl/Cmd+Shift+U) and select "Pi Agent" from the dropdown to view logs.
Enable Debug Logging
For detailed troubleshooting, enable debug mode:
- Open Settings (
Ctrl/Cmd+,)
- Search for "Pi: Debug"
- Check the box to enable
Or add to settings.json:
{
"pi.debug": true
}
Development
# Clone and install
git clone <repo-url>
cd vscode-pi-model-chat-provider
npm install
# Compile
npm run compile
# Watch mode
npm run watch
# Package
npx @vscode/vsce package
License
MIT
Links