diff options
| author | Aiden Cline <[email protected]> | 2025-12-16 13:42:21 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-16 15:42:21 -0600 |
| commit | 5f57cee8e46abc6b1368c10991a22b2d676cf2a4 (patch) | |
| tree | 3fde7bf2a850cdced6cad0e7d3c88e5658c610fd | |
| parent | 1755a3fe0778ca9021fe7b59218c1830826502bc (diff) | |
| download | opencode-5f57cee8e46abc6b1368c10991a22b2d676cf2a4.tar.gz opencode-5f57cee8e46abc6b1368c10991a22b2d676cf2a4.zip | |
fix: user invoked subtasks causing tool_use or missing thinking signa… (#5650)
| -rw-r--r-- | .opencode/command/commit.md | 1 | ||||
| -rw-r--r-- | packages/opencode/src/session/prompt.ts | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/.opencode/command/commit.md b/.opencode/command/commit.md index c318ed54b..8e9346ebc 100644 --- a/.opencode/command/commit.md +++ b/.opencode/command/commit.md @@ -1,6 +1,7 @@ --- description: git commit and push model: opencode/glm-4.6 +subtask: true --- commit and push diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index 3be4c45fd..4ae7469a3 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 } |
