feat: Phase 4 - LLM/Agent fallback chain, cross-agent knowledge sharing, async agent execution

- 4.1 Fallback chain: LLM fallback_llm config in AgentLLMConfig, retry with alternate model on API failure; Agent fallback_agent in DAG nodes
- 4.2 Knowledge sharing: GlobalKnowledge model with embedding-based semantic search, auto-extraction of tool names as tags after execution
- 4.3 Async execution: execute_agent_task fully implemented with AgentRuntime, scheduler dual-path for workflow/non-workflow agents

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
renjianbo
2026-05-05 00:27:54 +08:00
parent 7e00b027d4
commit 592bca4f39
7 changed files with 461 additions and 70 deletions

View File

@@ -50,3 +50,21 @@ class AgentExtension(Base):
def __repr__(self):
return f"<AgentExtension(id={self.id}, type={self.extension_type}, name={self.name})>"
class GlobalKnowledge(Base):
"""Agent 间知识共享表 — 跨 Agent 的全局知识池"""
__tablename__ = "global_knowledge"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="知识ID")
content = Column(Text, nullable=False, comment="知识内容摘要")
embedding = Column(Text, nullable=True, comment="内容 embeddingJSON 序列化)")
source_agent_id = Column(CHAR(36), nullable=True, comment="来源 Agent ID")
source_user_id = Column(CHAR(36), nullable=True, comment="来源用户 ID")
tags = Column(JSON, nullable=True, comment="分类标签")
scope_kind = Column(String(50), default="agent", comment="作用域类型")
scope_id = Column(String(100), default="", comment="作用域 ID")
created_at = Column(DateTime, default=func.now(), comment="创建时间")
def __repr__(self):
return f"<GlobalKnowledge(id={self.id}, source_agent={self.source_agent_id})>"