feat(server): 新增智能体运行服务,优化知识库索引存储结构,增强运行时状态管理

This commit is contained in:
caoxiaozhu
2026-05-15 09:34:21 +00:00
parent 6793b6f832
commit 11435468f1
8 changed files with 193 additions and 54 deletions

View File

@@ -115,6 +115,38 @@ class AgentRunService:
logger.info("Updated agent run run_id=%s status=%s", updated.run_id, updated.status)
return self._serialize_run(updated)
def merge_route_json(
self,
run_id: str,
route_patch: dict[str, Any],
*,
status: str | None = None,
result_summary: str | None = None,
error_message: str | None = None,
finished_at: datetime | None = None,
) -> AgentRunRead:
self._ensure_ready()
run = self.repository.get_by_run_id(run_id)
if run is None:
raise LookupError("Run not found")
route_json = dict(run.route_json or {})
route_json.update(route_patch or {})
run.route_json = route_json
if status is not None:
run.status = status
if result_summary is not None:
run.result_summary = result_summary
if error_message is not None:
run.error_message = error_message
if finished_at is not None:
run.finished_at = finished_at
updated = self.repository.save_run(run)
logger.info("Merged route_json for agent run run_id=%s status=%s", updated.run_id, updated.status)
return self._serialize_run(updated)
def record_tool_call(
self,
*,