feat: 实现 Agent 自主学习 — 从历史执行中优化工具选择

- 新增 AgentLearningPattern 模型和 agent_learning_service 服务
- 执行前注入历史学习模式到 system prompt 作为工具选择建议
- 执行后自动提取工具序列并保存/累计学习模式
- 支持任务分类(11类)、关键词提取、工具序列合并、有效性评分
- 集成到 AgentRuntime.run()/run_stream(),支持 bare chat 和 Agent 模式

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
renjianbo
2026-05-02 12:04:00 +08:00
parent c28cf40f61
commit e3802eff60
6 changed files with 459 additions and 7 deletions

View File

@@ -48,5 +48,6 @@ def init_db():
import app.models.alert_rule
import app.models.agent_llm_log
import app.models.agent_vector_memory
import app.models.agent_learning_pattern
import app.models.knowledge_base
Base.metadata.create_all(bind=engine)