summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax <[email protected]>2025-11-19 13:10:09 -0500
committerGitHub <[email protected]>2025-11-19 13:10:09 -0500
commit16fdc9097604cf5ec2fc822068cf17343689e3e5 (patch)
tree3be84efae0a4c192bdc1876023ed304dfcdfd86c
parent793542230f48933dcf48eb91d4d59b73b67f8066 (diff)
downloadopencode-16fdc9097604cf5ec2fc822068cf17343689e3e5.tar.gz
opencode-16fdc9097604cf5ec2fc822068cf17343689e3e5.zip
fix: resolve issue 4475 (#4505)
-rw-r--r--packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx6
-rw-r--r--packages/opencode/src/session/prompt.ts28
-rw-r--r--packages/sdk/js/src/gen/types.gen.ts4
3 files changed, 22 insertions, 16 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
index 848857ea1..8281ab617 100644
--- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
@@ -9,7 +9,7 @@ import {
fg,
type KeyBinding,
} from "@opentui/core"
-import { createEffect, createMemo, Match, Switch, type JSX, onMount, batch } from "solid-js"
+import { createEffect, createMemo, Match, Switch, type JSX, onMount } from "solid-js"
import { useLocal } from "@tui/context/local"
import { useTheme } from "@tui/context/theme"
import { SplitBorder } from "@tui/component/border"
@@ -425,6 +425,10 @@ export function Prompt(props: PromptProps) {
},
body: {
agent: local.agent.current().name,
+ model: {
+ providerID: local.model.current().providerID,
+ modelID: local.model.current().modelID,
+ },
command: inputText,
},
})
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 09168db31..443d24046 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -600,12 +600,9 @@ export namespace SessionPrompt {
throw new Error("Impossible")
})
- async function resolveModel(input: { model: PromptInput["model"]; agent: Agent.Info }) {
- if (input.model) {
- return input.model
- }
- if (input.agent.model) {
- return input.agent.model
+ async function lastModel(sessionID: string) {
+ for await (const item of MessageV2.stream(sessionID)) {
+ if (item.info.role === "user" && item.info.model) return item.info.model
}
return Provider.defaultModel()
}
@@ -794,10 +791,7 @@ export namespace SessionPrompt {
tools: input.tools,
system: input.system,
agent: agent.name,
- model: await resolveModel({
- model: input.model,
- agent,
- }),
+ model: input.model ?? agent.model ?? (await lastModel(input.sessionID)),
}
const parts = await Promise.all(
@@ -1091,6 +1085,12 @@ export namespace SessionPrompt {
export const ShellInput = z.object({
sessionID: Identifier.schema("session"),
agent: z.string(),
+ model: z
+ .object({
+ providerID: z.string(),
+ modelID: z.string(),
+ })
+ .optional(),
command: z.string(),
})
export type ShellInput = z.infer<typeof ShellInput>
@@ -1100,7 +1100,7 @@ export namespace SessionPrompt {
SessionRevert.cleanup(session)
}
const agent = await Agent.get(input.agent)
- const model = await resolveModel({ agent, model: undefined })
+ const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
const userMsg: MessageV2.User = {
id: Identifier.ascending("message"),
sessionID: input.sessionID,
@@ -1338,10 +1338,8 @@ export namespace SessionPrompt {
return cmdAgent.model
}
}
- if (input.model) {
- return Provider.parseModel(input.model)
- }
- return await Provider.defaultModel()
+ if (input.model) return Provider.parseModel(input.model)
+ return await lastModel(input.sessionID)
})()
const agent = await Agent.get(agentName)
diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts
index d9414d393..52cde5e58 100644
--- a/packages/sdk/js/src/gen/types.gen.ts
+++ b/packages/sdk/js/src/gen/types.gen.ts
@@ -2294,6 +2294,10 @@ export type SessionCommandResponse = SessionCommandResponses[keyof SessionComman
export type SessionShellData = {
body?: {
agent: string
+ model?: {
+ providerID: string
+ modelID: string
+ }
command: string
}
path: {