OpenCode plugin to switch agent modes between performance and economy presets
npm install opencode-agent-modes


!OpenCode Plugin
!TypeScript
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:
``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.md
- mode-status.md
- mode-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:
1. Reading current models from opencode.json for the "performance" presetopencode/glm-4.7-free
2. Setting for the "economy" preset
> [!TIP]
> The oh-my-opencode section is optional. Omit it if you don't use oh-my-opencode.
`json`
{
"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:
`text`
agent.
Agent-specific settings override the global model setting.
To add a custom preset (e.g., "premium"):
1. Add the preset to ~/.config/opencode/agent-mode-switcher.json:
`json`
{
"presets": {
"premium": {
"description": "High-end models for critical tasks",
"opencode": {
"build": { "model": "anthropic/claude-opus-4-5-20251101" }
}
}
}
}
2. Create a command file at ~/.config/opencode/command/mode-premium.md:
`md
---
description: "Switch to premium mode (high-end models)"
---
Use mode_switch tool to switch agent mode to "premium".
`
3. 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
> - Built-in command files (mode-performance.md, mode-economy.md, etc.)mode-premium.md
> are overwritten on every plugin startup. Do not modify them directly.
> - Custom command files (e.g., ) are not affected by
> this overwrite and will persist across restarts.
This project uses Bun as the runtime and package manager.
- Bun v1.0 or later
`bashClone the repository
git clone https://github.com/j4rviscmd/opencode-agent-modes.git
cd opencode-agent-modes