|
8 | 8 | buildToolIdList, |
9 | 9 | createSyntheticAssistantMessageWithToolPart, |
10 | 10 | isIgnoredUserMessage, |
11 | | - hasReasoningInCurrentAssistantTurn, |
12 | 11 | } from "./utils" |
13 | 12 | import { getFilePathFromParameters, isProtectedFilePath } from "../protected-file-patterns" |
14 | 13 | import { getLastUserMessage } from "../shared-utils" |
@@ -139,31 +138,16 @@ export const insertPruneToolContext = ( |
139 | 138 | return |
140 | 139 | } |
141 | 140 |
|
142 | | - const userInfo = lastUserMessage.info as UserMessage |
143 | | - const providerID = userInfo.model.providerID |
144 | | - const modelID = userInfo.model.modelID |
145 | | - const isGitHubCopilot = |
146 | | - providerID === "github-copilot" || providerID === "github-copilot-enterprise" |
147 | | - |
148 | | - // TODO: This can probably be improved further to only trigger for the appropriate thinking settings |
149 | | - // This setting is also potentially only necessary for claude subscription, API seems to not need this |
150 | | - // validation. See more here: https://platform.claude.com/docs/en/build-with-claude/extended-thinking |
151 | | - const isAnthropic = modelID.includes("claude") |
152 | | - |
153 | | - if (isGitHubCopilot) { |
154 | | - const lastMessage = messages[messages.length - 1] |
155 | | - if (lastMessage?.info?.role === "user" && !isIgnoredUserMessage(lastMessage)) { |
156 | | - return |
157 | | - } |
158 | | - } |
159 | | - |
160 | | - // Anthropic extended thinking models require a thinking block at the start of its turn |
161 | | - if (isAnthropic) { |
162 | | - if (!hasReasoningInCurrentAssistantTurn(messages)) { |
163 | | - return |
164 | | - } |
| 141 | + // Never inject immediately following a user message - wait until assistant has started its turn |
| 142 | + // This avoids interfering with model reasoning/thinking phases |
| 143 | + // TODO: This can be skipped if there is a good way to check if the model has reasoning, |
| 144 | + // can't find a good way to do this yet |
| 145 | + const lastMessage = messages[messages.length - 1] |
| 146 | + if (lastMessage?.info?.role === "user" && !isIgnoredUserMessage(lastMessage)) { |
| 147 | + return |
165 | 148 | } |
166 | 149 |
|
| 150 | + const userInfo = lastUserMessage.info as UserMessage |
167 | 151 | const variant = state.variant ?? userInfo.variant |
168 | 152 | messages.push( |
169 | 153 | createSyntheticAssistantMessageWithToolPart(lastUserMessage, prunableToolsContent, variant), |
|
0 commit comments