feat: pass mode into task tool (#1248)

This commit is contained in:
Yihui Khuu
2025-07-24 10:29:59 +10:00
committed by GitHub
parent 3e69d5276b
commit 507c975e92
4 changed files with 24 additions and 2 deletions

View File

@@ -370,6 +370,7 @@ export namespace Session {
const l = log.clone().tag("session", input.sessionID)
l.info("chatting")
const inputMode = input.mode ?? "build"
const userMsg: MessageV2.Info = {
id: input.messageID ?? Identifier.ascending("message"),
role: "user",
@@ -494,7 +495,7 @@ export namespace Session {
]
}),
).then((x) => x.flat())
if (input.mode === "plan")
if (inputMode === "plan")
userParts.push({
id: Identifier.ascending("part"),
messageID: userMsg.id,
@@ -617,7 +618,7 @@ export namespace Session {
.catch(() => {})
}
const mode = await Mode.get(input.mode ?? "build")
const mode = await Mode.get(inputMode)
let system = input.providerID === "anthropic" ? [PROMPT_ANTHROPIC_SPOOF.trim()] : []
system.push(...(mode.prompt ? [mode.prompt] : SystemPrompt.provider(input.modelID)))
system.push(...(await SystemPrompt.environment()))
@@ -630,6 +631,7 @@ export namespace Session {
id: Identifier.ascending("message"),
role: "assistant",
system,
mode: inputMode,
path: {
cwd: app.path.cwd,
root: app.path.root,
@@ -1122,6 +1124,7 @@ export namespace Session {
role: "assistant",
sessionID: input.sessionID,
system,
mode: "build",
path: {
cwd: app.path.cwd,
root: app.path.root,

View File

@@ -226,6 +226,7 @@ export namespace MessageV2 {
system: z.string().array(),
modelID: z.string(),
providerID: z.string(),
mode: z.string(),
path: z.object({
cwd: z.string(),
root: z.string(),
@@ -290,6 +291,7 @@ export namespace MessageV2 {
modelID: v1.metadata.assistant!.modelID,
providerID: v1.metadata.assistant!.providerID,
system: v1.metadata.assistant!.system,
mode: "build",
error: v1.metadata.error,
}
const parts = v1.parts.flatMap((part): Part[] => {