|
7 | 7 | extractParameterKey, |
8 | 8 | buildToolIdList, |
9 | 9 | createSyntheticAssistantMessageWithToolPart, |
10 | | - createSyntheticUserMessage, |
11 | 10 | } from "./utils" |
12 | 11 | import { getFilePathFromParameters, isProtectedFilePath } from "../protected-file-patterns" |
13 | 12 | import { getLastUserMessage } from "../shared-utils" |
@@ -140,25 +139,20 @@ export const insertPruneToolContext = ( |
140 | 139 |
|
141 | 140 | const userInfo = lastUserMessage.info as UserMessage |
142 | 141 | const providerID = userInfo.model.providerID |
| 142 | + const modelID = userInfo.model.modelID |
143 | 143 | const isGitHubCopilot = |
144 | 144 | providerID === "github-copilot" || providerID === "github-copilot-enterprise" |
| 145 | + const isAnthropic = modelID.includes("claude") |
145 | 146 |
|
146 | | - logger.info("Injecting prunable-tools list", { |
147 | | - providerID, |
148 | | - isGitHubCopilot, |
149 | | - injectionType: isGitHubCopilot ? "assistant-with-tool-part" : "user-message", |
150 | | - }) |
151 | | - |
152 | | - const variant = state.variant ?? (lastUserMessage.info as UserMessage).variant |
153 | | - if (isGitHubCopilot) { |
154 | | - messages.push( |
155 | | - createSyntheticAssistantMessageWithToolPart( |
156 | | - lastUserMessage, |
157 | | - prunableToolsContent, |
158 | | - variant, |
159 | | - ), |
160 | | - ) |
161 | | - } else { |
162 | | - messages.push(createSyntheticUserMessage(lastUserMessage, prunableToolsContent, variant)) |
| 147 | + if (isGitHubCopilot || isAnthropic) { |
| 148 | + const lastMessage = messages[messages.length - 1] |
| 149 | + if (lastMessage?.info?.role === "user") { |
| 150 | + return |
| 151 | + } |
163 | 152 | } |
| 153 | + |
| 154 | + const variant = state.variant ?? userInfo.variant |
| 155 | + messages.push( |
| 156 | + createSyntheticAssistantMessageWithToolPart(lastUserMessage, prunableToolsContent, variant), |
| 157 | + ) |
164 | 158 | } |
0 commit comments