refactor: 重构 AgentScope ReAct Runner 与事件处理

- 重构 runtime/runner.py 实现 ReAct Agent 核心逻辑
- 更新事件编码器与存储机制
- 优化 prompt 系统与 tool 调用
- 调整 agent service 与 repository 配合
This commit is contained in:
qzl
2026-03-16 16:10:39 +08:00
parent ab073c88ed
commit 36b104fa37
22 changed files with 1288 additions and 319 deletions
+23
View File
@@ -23,6 +23,10 @@ class UserRepository(Protocol):
"""Get user by user ID."""
...
async def get_by_user_ids(self, user_ids: list[UUID]) -> dict[UUID, Profile]:
"""Batch get users by user IDs."""
...
async def get_by_username(self, username: str) -> Profile | None:
"""Get user by username."""
...
@@ -57,6 +61,25 @@ class SQLAlchemyUserRepository(BaseRepository[Profile]):
logger.exception("User lookup failed", user_id=str(user_id))
raise
async def get_by_user_ids(self, user_ids: list[UUID]) -> dict[UUID, Profile]:
if not user_ids:
return {}
try:
unique_ids = list(dict.fromkeys(user_ids))
stmt = (
select(Profile)
.where(Profile.id.in_(unique_ids))
.where(Profile.deleted_at.is_(None))
)
result = await self._session.execute(stmt)
profiles = list(result.scalars().all())
return {profile.id: profile for profile in profiles}
except SQLAlchemyError:
logger.exception(
"Batch user lookup failed", user_ids=[str(i) for i in user_ids]
)
raise
async def get_by_username(self, username: str) -> Profile | None:
try:
stmt = (