Skip to content

Commit 65a5960

Browse files
committed
fix(agent): properly switch model when switching mode/agent
This should solves #112
1 parent d8a81b5 commit 65a5960

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lua/opencode/config_file.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,11 @@ function M.get_opencode_agents()
8585
end
8686
end
8787

88-
-- Sort the agents before prepending the default agents
8988
table.sort(agents)
9089

91-
-- Only add build/plan as fallbacks if they're not explicitly disabled in config
9290
for _, mode in ipairs({ 'plan', 'build' }) do
9391
if not vim.tbl_contains(agents, mode) then
9492
local mode_config = cfg.agent and cfg.agent[mode]
95-
-- Only add if not explicitly disabled or if no config exists (default behavior)
9693
if mode_config == nil or (mode_config.disable ~= true) then
9794
table.insert(agents, 1, mode)
9895
end

lua/opencode/core.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ function M.switch_to_mode(mode)
312312
end
313313

314314
state.current_mode = mode
315+
local agents_config = config_file.get_opencode_config().agent or {}
316+
local mode_config = agents_config[mode] or {}
317+
if mode_config.model and mode_config.model ~= '' then
318+
state.current_model = mode_config.model
319+
end
315320
return true
316321
end
317322

0 commit comments

Comments
 (0)