mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
fix 4475
This commit is contained in:
parent
b3afa84058
commit
2e0e72c4df
2 changed files with 8 additions and 15 deletions
|
|
@ -425,6 +425,7 @@ export function Prompt(props: PromptProps) {
|
|||
},
|
||||
body: {
|
||||
agent: local.agent.current().name,
|
||||
model: `${local.model.current().providerID}/${local.model.current().modelID}`,
|
||||
command: inputText,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
@ -1100,7 +1094,7 @@ export namespace SessionPrompt {
|
|||
SessionRevert.cleanup(session)
|
||||
}
|
||||
const agent = await Agent.get(input.agent)
|
||||
const model = await resolveModel({ agent, model: undefined })
|
||||
const model = agent.model ?? (await lastModel(input.sessionID))
|
||||
const userMsg: MessageV2.User = {
|
||||
id: Identifier.ascending("message"),
|
||||
sessionID: input.sessionID,
|
||||
|
|
@ -1338,10 +1332,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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue