feat: agent memory management — CRUD API + Android management screen
Some checks failed
CI/CD Pipeline / Backend — Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend — Lint & Build (push) Has been cancelled
CI/CD Pipeline / Docker — Build Check (push) Has been cancelled

Backend:
- New /api/v1/agents/{id}/memory endpoints: CRUD for global_knowledge,
  knowledge_entities, learning_patterns, vector_memories + import/export
- Fix scope_id column overflow: 3 model columns expanded to hold compound
  keys (user_id:agent_id format, 73 chars vs old VARCHAR(36))
- Config: allow unknown env vars (extra="ignore") for optional overrides

Android:
- MemoryManageScreen: 4-tab UI (全局知识/知识实体/学习模式/对话记忆)
  with search, delete, and FAB to add new entries
- Import/export via ShareSheet and file picker
- AgentListScreen: long-press dropdown menu → 记忆管理 entry point
- NavGraph: memory_manage/{agentId}/{agentName} route with URL encoding

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 02:23:45 +08:00
parent 43d5347458
commit cffe4a52d6
15 changed files with 1876 additions and 14 deletions

View File

@@ -11,7 +11,7 @@ class AgentLearningPattern(Base):
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
scope_kind = Column(String(16), nullable=False, index=True, comment="作用域类型: agent/bare")
scope_id = Column(String(64), nullable=False, index=True, comment="作用域 ID: agent_id/user_id")
scope_id = Column(String(255), nullable=False, index=True, comment="作用域 ID: agent_id/user_id")
task_category = Column(String(64), nullable=False, default="general", comment="任务分类")
task_keywords = Column(String(256), default="", comment="任务关键词")
suggested_tools = Column(Text, nullable=False, comment="推荐工具序列 (JSON array)")

View File

@@ -21,7 +21,7 @@ class AgentVectorMemory(Base):
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
scope_kind = Column(String(16), nullable=False, index=True, comment="作用域类型: agent / bare")
scope_id = Column(String(36), nullable=False, index=True, comment="作用域 ID: agent_id / user_id")
scope_id = Column(String(255), nullable=False, index=True, comment="作用域 ID: agent_id / user_id")
session_key = Column(String(128), nullable=False, default="", comment="会话标识")
content_text = Column(Text, nullable=False, comment="原始对话文本")
embedding = Column(Text, nullable=True, comment="JSON 序列化的 embedding 向量")

View File

@@ -19,7 +19,7 @@ class PersistentUserMemory(Base):
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="主键")
scope_kind = Column(String(16), nullable=False, comment="agent 或 workflow")
scope_id = Column(CHAR(36), nullable=False, comment="Agent ID 或 Workflow ID")
scope_id = Column(String(128), nullable=False, comment="Agent ID 或 Workflow ID")
session_key = Column(String(512), nullable=False, comment="调用方传入的 user_id 等会话键")
payload = Column(JSON, nullable=False, comment="与 Redis 中 user_memory_* 结构一致的记忆 JSON")
updated_at = Column(