File tree Expand file tree Collapse file tree 2 files changed +9
-48
lines changed
Expand file tree Collapse file tree 2 files changed +9
-48
lines changed Original file line number Diff line number Diff line change 77 extractParameterKey ,
88 buildToolIdList ,
99 createSyntheticAssistantMessageWithToolPart ,
10- createSyntheticUserMessage ,
1110} from "./utils"
1211import { getFilePathFromParameters , isProtectedFilePath } from "../protected-file-patterns"
1312import { getLastUserMessage } from "../shared-utils"
@@ -143,22 +142,15 @@ export const insertPruneToolContext = (
143142 const isGitHubCopilot =
144143 providerID === "github-copilot" || providerID === "github-copilot-enterprise"
145144
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
153145 if ( isGitHubCopilot ) {
154- messages . push (
155- createSyntheticAssistantMessageWithToolPart (
156- lastUserMessage ,
157- prunableToolsContent ,
158- variant ,
159- ) ,
160- )
161- } else {
162- messages . push ( createSyntheticUserMessage ( lastUserMessage , prunableToolsContent , variant ) )
146+ const lastMessage = messages [ messages . length - 1 ]
147+ if ( lastMessage ?. info ?. role === "user" ) {
148+ return
149+ }
163150 }
151+
152+ const variant = state . variant ?? userInfo . variant
153+ messages . push (
154+ createSyntheticAssistantMessageWithToolPart ( lastUserMessage , prunableToolsContent , variant ) ,
155+ )
164156}
Original file line number Diff line number Diff line change @@ -7,37 +7,6 @@ const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345"
77const SYNTHETIC_PART_ID = "prt_01234567890123456789012345"
88const SYNTHETIC_CALL_ID = "call_01234567890123456789012345"
99
10- export const createSyntheticUserMessage = (
11- baseMessage : WithParts ,
12- content : string ,
13- variant ?: string ,
14- ) : WithParts => {
15- const userInfo = baseMessage . info as UserMessage
16- return {
17- info : {
18- id : SYNTHETIC_MESSAGE_ID ,
19- sessionID : userInfo . sessionID ,
20- role : "user" ,
21- time : { created : Date . now ( ) } ,
22- agent : userInfo . agent || "code" ,
23- model : {
24- providerID : userInfo . model . providerID ,
25- modelID : userInfo . model . modelID ,
26- } ,
27- ...( variant !== undefined && { variant } ) ,
28- } ,
29- parts : [
30- {
31- id : SYNTHETIC_PART_ID ,
32- sessionID : userInfo . sessionID ,
33- messageID : SYNTHETIC_MESSAGE_ID ,
34- type : "text" ,
35- text : content ,
36- } ,
37- ] ,
38- }
39- }
40-
4110export const createSyntheticAssistantMessageWithToolPart = (
4211 baseMessage : WithParts ,
4312 content : string ,
You can’t perform that action at this time.
0 commit comments