mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-03 15:43:45 +00:00
fix(opencode): scope agent variant to model (#11410)
This commit is contained in:
@@ -37,6 +37,7 @@ export namespace Agent {
|
||||
providerID: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
variant: z.string().optional(),
|
||||
prompt: z.string().optional(),
|
||||
options: z.record(z.string(), z.any()),
|
||||
steps: z.number().int().positive().optional(),
|
||||
@@ -214,6 +215,7 @@ export namespace Agent {
|
||||
native: false,
|
||||
}
|
||||
if (value.model) item.model = Provider.parseModel(value.model)
|
||||
item.variant = value.variant ?? item.variant
|
||||
item.prompt = value.prompt ?? item.prompt
|
||||
item.description = value.description ?? item.description
|
||||
item.temperature = value.temperature ?? item.temperature
|
||||
|
||||
@@ -593,6 +593,10 @@ export namespace Config {
|
||||
export const Agent = z
|
||||
.object({
|
||||
model: z.string().optional(),
|
||||
variant: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Default model variant for this agent (applies only when using the agent's configured model)."),
|
||||
temperature: z.number().optional(),
|
||||
top_p: z.number().optional(),
|
||||
prompt: z.string().optional(),
|
||||
@@ -624,6 +628,7 @@ export namespace Config {
|
||||
const knownKeys = new Set([
|
||||
"name",
|
||||
"model",
|
||||
"variant",
|
||||
"prompt",
|
||||
"description",
|
||||
"temperature",
|
||||
|
||||
@@ -827,6 +827,17 @@ export namespace SessionPrompt {
|
||||
|
||||
async function createUserMessage(input: PromptInput) {
|
||||
const agent = await Agent.get(input.agent ?? (await Agent.defaultAgent()))
|
||||
|
||||
const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
|
||||
const variant =
|
||||
input.variant ??
|
||||
(agent.variant &&
|
||||
agent.model &&
|
||||
model.providerID === agent.model.providerID &&
|
||||
model.modelID === agent.model.modelID
|
||||
? agent.variant
|
||||
: undefined)
|
||||
|
||||
const info: MessageV2.Info = {
|
||||
id: input.messageID ?? Identifier.ascending("message"),
|
||||
role: "user",
|
||||
@@ -836,9 +847,9 @@ export namespace SessionPrompt {
|
||||
},
|
||||
tools: input.tools,
|
||||
agent: agent.name,
|
||||
model: input.model ?? agent.model ?? (await lastModel(input.sessionID)),
|
||||
model,
|
||||
system: input.system,
|
||||
variant: input.variant,
|
||||
variant,
|
||||
}
|
||||
using _ = defer(() => InstructionPrompt.clear(info.id))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user