File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
packages/core/src/codewhispererChat Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,19 @@ import { ToolkitError } from '../../../../shared/errors'
1414import { createCodeWhispererChatStreamingClient } from '../../../../shared/clients/codewhispererChatClient'
1515import { createQDeveloperStreamingClient } from '../../../../shared/clients/qDeveloperChatClient'
1616import { UserWrittenCodeTracker } from '../../../../codewhisperer/tracker/userWrittenCodeTracker'
17+ import { PromptMessage } from '../../../controllers/chat/model'
1718
1819export class ChatSession {
1920 private sessionId ?: string
2021 /**
2122 * _readFiles = list of files read from the project to gather context before generating response.
2223 * _showDiffOnFileWrite = Controls whether to show diff view (true) or file context view (false) to the user
24+ * _context = Additional context to be passed to the LLM for generating the response
2325 */
2426 private _readFiles : string [ ] = [ ]
2527 private _toolUse : ToolUse | undefined
2628 private _showDiffOnFileWrite : boolean = false
29+ private _context : PromptMessage [ 'context' ]
2730
2831 contexts : Map < string , { first : number ; second : number } [ ] > = new Map ( )
2932 // TODO: doesn't handle the edge case when two files share the same relativePath string but from different root
@@ -41,6 +44,14 @@ export class ChatSession {
4144 this . _toolUse = toolUse
4245 }
4346
47+ public get context ( ) : PromptMessage [ 'context' ] {
48+ return this . _context
49+ }
50+
51+ public setContext ( context : PromptMessage [ 'context' ] ) {
52+ this . _context = context
53+ }
54+
4455 public tokenSource ! : vscode . CancellationTokenSource
4556
4657 constructor ( ) {
Original file line number Diff line number Diff line change @@ -709,7 +709,7 @@ export class ChatController {
709709 toolResults : toolResults ,
710710 origin : Origin . IDE ,
711711 chatHistory : this . chatHistoryManager . getHistory ( ) ,
712- context : [ ] ,
712+ context : session . context ?? [ ] ,
713713 relevantTextDocuments : [ ] ,
714714 additionalContents : [ ] ,
715715 documentReferences : [ ] ,
@@ -1081,6 +1081,10 @@ export class ChatController {
10811081 type : 'chat_message' ,
10821082 context,
10831083 } )
1084+
1085+ // Save the context for the agentic loop
1086+ session . setContext ( message . context )
1087+
10841088 await this . generateResponse (
10851089 {
10861090 message : message . message ?? '' ,
You can’t perform that action at this time.
0 commit comments