OpenCode plugin to switch agent models between performance and economy modes.
Note
Primary Use Case: When approaching your token limit, switch to pre-defined economy models to extend your session until your quota resets. Changes take effect after restarting opencode.
- Switch between different model presets (performance, economy, or custom)
- Configurable presets with user-defined models
- Toast notifications for mode changes
| Agent Type | Description |
|---|---|
| opencode agents | Standard agents (build, plan, etc.) |
| oh-my-opencode agents | Optional - applies if oh-my-opencode is installed |
Add the plugin to your opencode.json:
{
"plugin": ["opencode-agent-modes@latest"]
}The following command files are automatically copied to
~/.config/opencode/command/ when the plugin initializes:
mode-performance.mdmode-economy.mdmode-status.mdmode-list.md
/mode-performance- Switch to high-performance models/mode-economy- Switch to cost-efficient free models/mode-status- Show current mode and configuration/mode-list- List all available mode presets
mode_switch- Switch to a specified mode presetmode_status- Display current mode settingsmode_list- List all available presets
The plugin configuration is stored at ~/.config/opencode/agent-mode-switcher.json.
On first run, the plugin automatically generates this file by:
- Reading current models from
opencode.jsonfor the "performance" preset - Setting
opencode/glm-4.7-freefor the "economy" preset
Tip
The oh-my-opencode section is optional. Omit it if you don't use oh-my-opencode.
{
"currentMode": "performance",
"showToastOnStartup": true,
"presets": {
"performance": {
"description": "High-performance models for complex tasks",
"opencode": {
"build": { "model": "github-copilot/gpt-5.2" },
"plan": { "model": "github-copilot/gpt-5.2" }
},
"oh-my-opencode": {
"Sisyphus": { "model": "anthropic/claude-opus-4-5-20251101" }
}
},
"economy": {
"description": "Cost-efficient free model for routine tasks",
"opencode": {
"build": { "model": "opencode/glm-4.7-free" }
},
"oh-my-opencode": {
"Sisyphus": { "model": "opencode/glm-4.7-free" }
}
}
}
}When both global model and agent-specific opencode settings are configured,
the priority is:
agent.<name>.model > model (global)
Agent-specific settings override the global model setting.
To add a custom preset (e.g., "premium"):
-
Add the preset to
~/.config/opencode/agent-mode-switcher.json:{ "presets": { "premium": { "description": "High-end models for critical tasks", "opencode": { "build": { "model": "anthropic/claude-opus-4-5-20251101" } } } } } -
Create a command file at
~/.config/opencode/command/mode-premium.md:--- description: "Switch to premium mode (high-end models)" --- Use mode_switch tool to switch agent mode to "premium".
-
Restart opencode to apply changes.
[!INFO]
- Changes require an opencode restart to take effect
- Custom mode presets can be added by editing the configuration file
This project uses Bun as the runtime and package manager.
- Bun v1.0 or later
# Clone the repository
git clone https://github.com/j4rviscmd/opencode-agent-modes.git
cd opencode-agent-modes
# Install dependencies
bun install
# Run tests
bun test
# Type check
bun run typecheck
# Lint & format
bun run lint
bun run format
# Build
bun run build