mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Persist API conversation history locally instead of in state as there seems to be an issue with some messages not being stringifyable
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "claude-dev",
|
||||
"version": "1.0.84",
|
||||
"version": "1.0.85",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "claude-dev",
|
||||
"version": "1.0.84",
|
||||
"version": "1.0.85",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.24.3",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "claude-dev",
|
||||
"displayName": "Claude Dev",
|
||||
"description": "Autonomous software engineer right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.",
|
||||
"version": "1.0.84",
|
||||
"version": "1.0.85",
|
||||
"icon": "icon.png",
|
||||
"engines": {
|
||||
"vscode": "^1.84.0"
|
||||
|
||||
@@ -41,7 +41,6 @@ RULES
|
||||
path.join(os.homedir(), "Desktop")
|
||||
}
|
||||
- Your current working directory is '${process.cwd()}', and you cannot \`cd\` into a different directory to complete a task. You are stuck operating from '${process.cwd()}', so be sure to pass in the appropriate 'path' parameter when using tools that require a path.
|
||||
- If you do not know the contents of an existing file you need to edit, use the read_file tool to help you make informed changes. However if you have already read or written to this file before, you can assume its contents have not changed since then so you would not need to call the read_file tool beforehand.
|
||||
- When editing files, always provide the complete file content in your response, regardless of the extent of changes. The system handles diff generation automatically.
|
||||
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system.
|
||||
- When creating a new project (such as an app, website, or any software project), unless the user specifies otherwise, organize all new files within a dedicated project directory. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
|
||||
|
||||
@@ -440,22 +440,33 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
|
||||
// conversation history to send in API requests
|
||||
|
||||
/*
|
||||
It seems that some API messages do not comply with vscode state requirements. Either the Anthropic library is manipulating these values somehow in the backend in a way thats creating cyclic references, or the API returns a function or a Symbol as part of the message content.
|
||||
VSCode docs about state: "The value must be JSON-stringifyable ... value — A value. MUST not contain cyclic references."
|
||||
For now we'll store the conversation history in memory, and if we need to store in state directly we'd need to do a manual conversion to ensure proper json stringification.
|
||||
*/
|
||||
private apiConversationHistory: Anthropic.MessageParam[] = []
|
||||
|
||||
async getApiConversationHistory(): Promise<Anthropic.MessageParam[]> {
|
||||
const history = (await this.getGlobalState(
|
||||
this.getApiConversationHistoryStateKey()
|
||||
)) as Anthropic.MessageParam[]
|
||||
return history || []
|
||||
// const history = (await this.getGlobalState(
|
||||
// this.getApiConversationHistoryStateKey()
|
||||
// )) as Anthropic.MessageParam[]
|
||||
// return history || []
|
||||
return this.apiConversationHistory
|
||||
}
|
||||
|
||||
async setApiConversationHistory(history: Anthropic.MessageParam[] | undefined) {
|
||||
await this.updateGlobalState(this.getApiConversationHistoryStateKey(), history)
|
||||
// await this.updateGlobalState(this.getApiConversationHistoryStateKey(), history)
|
||||
this.apiConversationHistory = history || []
|
||||
}
|
||||
|
||||
async addMessageToApiConversationHistory(message: Anthropic.MessageParam): Promise<Anthropic.MessageParam[]> {
|
||||
const history = await this.getApiConversationHistory()
|
||||
history.push(message)
|
||||
await this.setApiConversationHistory(history)
|
||||
return history
|
||||
// const history = await this.getApiConversationHistory()
|
||||
// history.push(message)
|
||||
// await this.setApiConversationHistory(history)
|
||||
// return history
|
||||
this.apiConversationHistory.push(message)
|
||||
return this.apiConversationHistory
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user