The open source coding agent.
TypeScript
fix: user invoked subtasks causing tool_use or missing thinking signa… (#5650)
Aiden Cline5f57cee8e46a
diff --git a/.opencode/command/commit.md b/.opencode/command/commit.mdindex c318ed54b1a..8e9346ebc88 100644--- a/.opencode/command/commit.md+++ b/.opencode/command/commit.md@@ -1,6 +1,7 @@---description: git commit and pushmodel: opencode/glm-4.6+subtask: true---commit and pushdiff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.tsindex 3be4c45fd60..4ae7469a309 100644--- a/packages/opencode/src/session/prompt.ts+++ b/packages/opencode/src/session/prompt.ts@@ -396,6 +396,30 @@ export namespace SessionPrompt {},} satisfies MessageV2.ToolPart)}++ // Add synthetic user message to prevent certain reasoning models from erroring+ // If we create assistant messages w/ out user ones following mid loop thinking signatures+ // will be missing and it can cause errors for models like gemini for example+ const summaryUserMsg: MessageV2.User = {+ id: Identifier.ascending("message"),+ sessionID,+ role: "user",+ time: {+ created: Date.now(),+ },+ agent: lastUser.agent,+ model: lastUser.model,+ }+ await Session.updateMessage(summaryUserMsg)+ await Session.updatePart({+ id: Identifier.ascending("part"),+ messageID: summaryUserMsg.id,+ sessionID,+ type: "text",+ text: "Summarize the task tool output above and continue with your task.",+ synthetic: true,+ } satisfies MessageV2.TextPart)+continue}