feat:记录会话,按顺序记录AI和用户的会话

- 包含工具调用等
This commit is contained in:
Roe-xin
2025-12-25 15:13:15 +08:00
parent ef83016b7f
commit 25a8ea5aa4
2 changed files with 51 additions and 0 deletions

View File

@ -333,6 +333,24 @@ export class ChatHistoryManager {
await this.saveConversation(messages);
}
/**
* 添加工具执行结果消息
*/
public async addToolExecutionResult(id: string, toolName: string, result: string): Promise<void> {
await this.ensureCurrentTask();
const messages = await this.loadConversation();
const toolResultMessage: ToolExecutionResultMessage = {
type: MessageType.TOOL_EXECUTION_RESULT,
id,
toolName,
text: result
};
messages.push(toolResultMessage);
await this.saveConversation(messages);
}
/**
* 记录对话轮次元数据
*/