From 44888094d0e505723fb1441b22e70033e927cae3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 07:12:38 +0000 Subject: [PATCH 1/3] Initial plan From fb05161f10cb5db4b2f88e8e361e024a104add9f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 07:18:33 +0000 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=99=BA=E8=83=BD?= =?UTF-8?q?=E4=BD=93=E9=85=8D=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=BC=BA=E5=B0=91agent=5Fid=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/xerrors/Yuxi/sessions/933d6368-5424-4327-99cf-3722768afa57 Co-authored-by: xerrors <35524243+xerrors@users.noreply.github.com> --- backend/server/routers/chat_router.py | 1 + backend/test/test_chat_router_configs.py | 70 ++++++++++++++++++++++++ docs/develop-guides/roadmap.md | 1 + 3 files changed, 72 insertions(+) create mode 100644 backend/test/test_chat_router_configs.py diff --git a/backend/server/routers/chat_router.py b/backend/server/routers/chat_router.py index 90f8c150b..1965e2e40 100644 --- a/backend/server/routers/chat_router.py +++ b/backend/server/routers/chat_router.py @@ -208,6 +208,7 @@ async def list_agent_configs( if not items: await repo.get_or_create_default( department_id=current_user.department_id, + agent_id=agent_id, created_by=str(current_user.id), ) items = await repo.list_by_department_agent(department_id=current_user.department_id, agent_id=agent_id) diff --git a/backend/test/test_chat_router_configs.py b/backend/test/test_chat_router_configs.py new file mode 100644 index 000000000..e99bdaf2d --- /dev/null +++ b/backend/test/test_chat_router_configs.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from fastapi import FastAPI +from fastapi.testclient import TestClient + +from server.routers.chat_router import chat +from server.utils.auth_middleware import get_db, get_required_user +from yuxi.storage.postgres.models_business import User + + +def _build_app() -> FastAPI: + app = FastAPI() + app.include_router(chat, prefix="/api") + + async def fake_db(): + return None + + async def fake_required_user(): + return User( + username="admin", + user_id="admin", + password_hash="x", + role="admin", + department_id=1, + id=1, + ) + + app.dependency_overrides[get_db] = fake_db + app.dependency_overrides[get_required_user] = fake_required_user + return app + + +def test_list_agent_configs_creates_default_with_agent_id(monkeypatch): + agent_id = "demo-agent" + captured: dict[str, object] = {} + + class DummyConfig: + id = 1 + name = "初始配置" + description = None + icon = None + pics = [] + examples = [] + is_default = True + + class DummyRepo: + def __init__(self, _db): + self.calls = 0 + + async def list_by_department_agent(self, *, department_id, agent_id): + self.calls += 1 + if self.calls == 1: + return [] + return [DummyConfig()] + + async def get_or_create_default(self, *, department_id, agent_id, created_by=None): + captured["department_id"] = department_id + captured["agent_id"] = agent_id + captured["created_by"] = created_by + return None + + monkeypatch.setattr("server.routers.chat_router.agent_manager.get_agent", lambda _agent_id: object()) + monkeypatch.setattr("server.routers.chat_router.AgentConfigRepository", DummyRepo) + + client = TestClient(_build_app()) + resp = client.get(f"/api/chat/agent/{agent_id}/configs") + assert resp.status_code == 200, resp.text + assert captured["agent_id"] == agent_id + assert captured["department_id"] == 1 + assert captured["created_by"] == "1" diff --git a/docs/develop-guides/roadmap.md b/docs/develop-guides/roadmap.md index dafbe9b95..7ac9c3902 100644 --- a/docs/develop-guides/roadmap.md +++ b/docs/develop-guides/roadmap.md @@ -64,6 +64,7 @@ - 修复前端工具图标与渲染匹配不准确的问题:工具管理列表与工具调用结果统一改为基于工具 `id` 的精确映射,避免模糊匹配导致的误渲染,未命中的工具不再显示默认扳手图标 - 修复 GitHub Pages 文档部署工作流失败:移除 `actions/setup-node@v4` 对不存在 `docs/package-lock.json` 的缓存依赖,并将 `docs` 目录安装命令从 `npm ci` 调整为 `npm install`,避免因未提交锁文件导致 CI 在依赖缓存和安装阶段直接失败 - 修正沙盒 provisioner backend 命名与配置说明:统一对外使用 `docker` / `kubernetes`,保留 `local` 作为兼容别名;同步清理 compose 中未生效的 provisioner 环境变量、补齐 K8s 相关变量注释,并更新沙盒架构文档中的默认模式与 backend 描述 +- 修复智能体配置列表接口在“无配置自动创建默认配置”路径下的参数缺失:补齐 `get_or_create_default` 的 `agent_id` 入参,避免 `/api/chat/agent/{agent_id}/configs` 返回 500 From f91e931a244186c8140dc1b1f40ae0ebc0449b39 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Mon, 30 Mar 2026 15:22:54 +0800 Subject: [PATCH 3/3] Delete backend/test/test_chat_router_configs.py --- backend/test/test_chat_router_configs.py | 70 ------------------------ 1 file changed, 70 deletions(-) delete mode 100644 backend/test/test_chat_router_configs.py diff --git a/backend/test/test_chat_router_configs.py b/backend/test/test_chat_router_configs.py deleted file mode 100644 index e99bdaf2d..000000000 --- a/backend/test/test_chat_router_configs.py +++ /dev/null @@ -1,70 +0,0 @@ -from __future__ import annotations - -from fastapi import FastAPI -from fastapi.testclient import TestClient - -from server.routers.chat_router import chat -from server.utils.auth_middleware import get_db, get_required_user -from yuxi.storage.postgres.models_business import User - - -def _build_app() -> FastAPI: - app = FastAPI() - app.include_router(chat, prefix="/api") - - async def fake_db(): - return None - - async def fake_required_user(): - return User( - username="admin", - user_id="admin", - password_hash="x", - role="admin", - department_id=1, - id=1, - ) - - app.dependency_overrides[get_db] = fake_db - app.dependency_overrides[get_required_user] = fake_required_user - return app - - -def test_list_agent_configs_creates_default_with_agent_id(monkeypatch): - agent_id = "demo-agent" - captured: dict[str, object] = {} - - class DummyConfig: - id = 1 - name = "初始配置" - description = None - icon = None - pics = [] - examples = [] - is_default = True - - class DummyRepo: - def __init__(self, _db): - self.calls = 0 - - async def list_by_department_agent(self, *, department_id, agent_id): - self.calls += 1 - if self.calls == 1: - return [] - return [DummyConfig()] - - async def get_or_create_default(self, *, department_id, agent_id, created_by=None): - captured["department_id"] = department_id - captured["agent_id"] = agent_id - captured["created_by"] = created_by - return None - - monkeypatch.setattr("server.routers.chat_router.agent_manager.get_agent", lambda _agent_id: object()) - monkeypatch.setattr("server.routers.chat_router.AgentConfigRepository", DummyRepo) - - client = TestClient(_build_app()) - resp = client.get(f"/api/chat/agent/{agent_id}/configs") - assert resp.status_code == 200, resp.text - assert captured["agent_id"] == agent_id - assert captured["department_id"] == 1 - assert captured["created_by"] == "1"