fix: 智能体使用记录改为发送第一条消息时才记录

This commit is contained in:
2026-04-26 23:52:14 +08:00
parent e6b3465aa7
commit 0303ccabc0
2 changed files with 8 additions and 6 deletions

View File

@@ -634,9 +634,6 @@ function openAgent(agentId) {
currentAgent = agents.find(a => a.id === agentId);
if (!currentAgent) return;
// 记录智能体使用历史
recordAgentUsage(agentId);
// 创建新对话并设置智能体
createNewConversation();
currentConversation.agentId = agentId;
@@ -1565,6 +1562,11 @@ async function sendMessage() {
// 隐藏欢迎界面
welcome.style.display = 'none';
// 如果是智能体对话的第一条消息,记录智能体使用
if (currentConversation.agentId && currentConversation.messages.length === 0) {
recordAgentUsage(currentConversation.agentId);
}
// 添加用户消息
currentConversation.messages.push({ role: 'user', content: text });