Skip to content

Commit 5f57cee

Browse files
authored
fix: user invoked subtasks causing tool_use or missing thinking signa… (anomalyco#5650)
1 parent 1755a3f commit 5f57cee

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

.opencode/command/commit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
description: git commit and push
33
model: opencode/glm-4.6
4+
subtask: true
45
---
56

67
commit and push

packages/opencode/src/session/prompt.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,30 @@ export namespace SessionPrompt {
396396
},
397397
} satisfies MessageV2.ToolPart)
398398
}
399+
400+
// Add synthetic user message to prevent certain reasoning models from erroring
401+
// If we create assistant messages w/ out user ones following mid loop thinking signatures
402+
// will be missing and it can cause errors for models like gemini for example
403+
const summaryUserMsg: MessageV2.User = {
404+
id: Identifier.ascending("message"),
405+
sessionID,
406+
role: "user",
407+
time: {
408+
created: Date.now(),
409+
},
410+
agent: lastUser.agent,
411+
model: lastUser.model,
412+
}
413+
await Session.updateMessage(summaryUserMsg)
414+
await Session.updatePart({
415+
id: Identifier.ascending("part"),
416+
messageID: summaryUserMsg.id,
417+
sessionID,
418+
type: "text",
419+
text: "Summarize the task tool output above and continue with your task.",
420+
synthetic: true,
421+
} satisfies MessageV2.TextPart)
422+
399423
continue
400424
}
401425

0 commit comments

Comments
 (0)