feat: add Suyao Feishu bot and per-agent memory config support
- Create suyao_app_service.py and suyao_ws_handler.py for 苏瑶 Feishu bot
- Add SUYAO_APP_ID/SUYAO_APP_SECRET/SUYAO_AGENT_ID config fields
- Fix node config extraction bug (n.get("config") → n.get("data")) in all WS handlers
- Add _build_memory_config_from_node() to support per-agent memory settings
(max_history_messages, vector_memory_top_k, persist_to_db, etc.)
- Create 苏瑶1号 (Plan A: long context), 苏瑶2号 (Plan B: emotion tracking),
苏瑶3号 (Plan C: knowledge graph + RAG) agents with different memory strategies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ from app.agent_runtime import (
|
||||
AgentLLMConfig,
|
||||
AgentToolConfig,
|
||||
AgentBudgetConfig,
|
||||
AgentMemoryConfig,
|
||||
AgentStep,
|
||||
AgentOrchestrator,
|
||||
OrchestratorAgentConfig,
|
||||
@@ -293,6 +294,7 @@ async def chat_with_agent(
|
||||
|
||||
uid = current_user.id
|
||||
mem_scope = f"{uid}:{agent_id}" if uid else str(agent_id)
|
||||
memory_cfg = _build_memory_config_from_node(agent_node_cfg)
|
||||
config = AgentConfig(
|
||||
name=agent.name,
|
||||
system_prompt=system_prompt,
|
||||
@@ -306,6 +308,7 @@ async def chat_with_agent(
|
||||
include_tools=agent_node_cfg.get("tools", []),
|
||||
exclude_tools=agent_node_cfg.get("exclude_tools", []),
|
||||
),
|
||||
memory=memory_cfg,
|
||||
budget=budget,
|
||||
user_id=uid,
|
||||
memory_scope_id=mem_scope,
|
||||
@@ -360,6 +363,7 @@ async def chat_with_agent_stream(
|
||||
|
||||
uid = current_user.id
|
||||
mem_scope = f"{uid}:{agent_id}" if uid else str(agent_id)
|
||||
memory_cfg = _build_memory_config_from_node(agent_node_cfg)
|
||||
config = AgentConfig(
|
||||
name=agent.name,
|
||||
system_prompt=system_prompt,
|
||||
@@ -373,6 +377,7 @@ async def chat_with_agent_stream(
|
||||
include_tools=agent_node_cfg.get("tools", []),
|
||||
exclude_tools=agent_node_cfg.get("exclude_tools", []),
|
||||
),
|
||||
memory=memory_cfg,
|
||||
budget=budget,
|
||||
user_id=uid,
|
||||
memory_scope_id=mem_scope,
|
||||
@@ -400,3 +405,14 @@ def _find_agent_node_config(nodes: list) -> Dict[str, Any]:
|
||||
if typ in ("agent", "llm", "template"):
|
||||
return node.get("data") or {}
|
||||
return {}
|
||||
|
||||
|
||||
def _build_memory_config_from_node(agent_node_cfg: dict) -> AgentMemoryConfig:
|
||||
"""从 Agent 工作流节点配置中提取记忆配置。"""
|
||||
return AgentMemoryConfig(
|
||||
max_history_messages=int(agent_node_cfg.get("memory_max_history", 20)),
|
||||
vector_memory_top_k=int(agent_node_cfg.get("memory_vector_top_k", 5)),
|
||||
persist_to_db=bool(agent_node_cfg.get("memory_persist", True)),
|
||||
vector_memory_enabled=bool(agent_node_cfg.get("memory_vector_enabled", True)),
|
||||
learning_enabled=bool(agent_node_cfg.get("memory_learning", True)),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user