Skip to content

Commit cc66e06

Browse files
authored
fix: command model selection (anomalyco#2219)
1 parent d4c8d95 commit cc66e06

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/opencode/src/session/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,12 +1171,16 @@ export namespace Session {
11711171

11721172
export async function command(input: CommandInput) {
11731173
const command = await Command.get(input.command)
1174-
const agent = input.agent ?? command.agent ?? "build"
1174+
const agent = command.agent ?? input.agent ?? "build"
1175+
const fmtModel = (model: { providerID: string; modelID: string }) => `${model.providerID}/${model.modelID}`
1176+
11751177
const model =
1176-
input.model ??
11771178
command.model ??
1178-
(await Agent.get(agent).then((x) => (x.model ? `${x.model.providerID}/${x.model.modelID}` : undefined))) ??
1179-
(await Provider.defaultModel().then((x) => `${x.providerID}/${x.modelID}`))
1179+
(command.agent && (await Agent.get(command.agent).then((x) => (x.model ? fmtModel(x.model) : undefined)))) ??
1180+
input.model ??
1181+
(input.agent && (await Agent.get(input.agent).then((x) => (x.model ? fmtModel(x.model) : undefined)))) ??
1182+
fmtModel(await Provider.defaultModel())
1183+
11801184
let template = command.template.replace("$ARGUMENTS", input.arguments)
11811185

11821186
const bash = Array.from(template.matchAll(bashRegex))

packages/tui/internal/app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,8 @@ func (a *App) SendCommand(ctx context.Context, command string, args string) (*Ap
820820
opencode.SessionCommandParams{
821821
Command: opencode.F(command),
822822
Arguments: opencode.F(args),
823+
Agent: opencode.F(a.Agents[a.AgentIndex].Name),
824+
Model: opencode.F(a.State.Provider + "/" + a.State.Model),
823825
},
824826
)
825827
if err != nil {

0 commit comments

Comments
 (0)