Commit 2e287500 by sunqi02 Committed by 胡悦

feat(loader): add load_agents_from_db, remove JSON-based loading

- New load_agents_from_db() reads ai_agents + ai_agent_skills tables
- Delete load_agents(), load_account_mappings()
- Dict key = ai_agents.code, AgentConfig.code = str(ai_agents.id)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 3a387c2c
......@@ -10,8 +10,6 @@ from app.config.settings import AgentConfig, ModelConfig, Settings
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
class ConfigLoadError(Exception):
"""Raised when config loading or validation fails."""
......@@ -56,8 +54,7 @@ class ConfigLoader:
result[key] = AgentConfig(
name=row.name,
code=str(row.id),
prompt=row.prompt or row.description or "",
description=row.description or "",
prompt=row.description or "",
skills=skills,
is_steward=row.is_steward,
)
......
......@@ -10,16 +10,14 @@ class TestLoadAgentsFromDb:
def _seed_agents(self, db_session):
steward = Agent(
name="管家 AGENT", code="agent_steward_001",
prompt="你是智能助手,负责协调各个岗位Agent协作回答用户问题。",
description="协调调度各子Agent,分析用户意图并分发任务",
description="你是智能助手,负责协调各个岗位Agent协作回答用户问题。",
is_steward=True, is_deleted=False,
)
db_session.add(steward)
db_session.flush()
sub = Agent(
name="会议Agent", code="agent_meeting_001",
prompt="你是会议纪要助手,负责处理会议纪要相关的任务。",
description="会议录音转写、会议纪要生成与导出",
description="你是会议纪要助手,负责处理会议纪要相关的任务。",
is_steward=False, is_deleted=False,
)
db_session.add(sub)
......@@ -67,13 +65,10 @@ class TestLoadAgentsFromDb:
steward = result["agent_steward_001"]
assert steward.name == "管家 AGENT"
assert steward.prompt == "你是智能助手,负责协调各个岗位Agent协作回答用户问题。"
assert steward.description == "协调调度各子Agent,分析用户意图并分发任务"
assert steward.is_steward is True
assert steward.skills == []
sub = result["agent_meeting_001"]
assert sub.name == "会议Agent"
assert sub.prompt == "你是会议纪要助手,负责处理会议纪要相关的任务。"
assert sub.description == "会议录音转写、会议纪要生成与导出"
assert sub.is_steward is False
assert sub.skills == ["meeting_minutes"]
self._clean_agents(db_session)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!