fischer-agentkit/tests
Chiguyong 7e7fcda3fe fix(portal/chat): 修复 400 错误 + 工具不执行 + 对话列表报错记录反复出现
三个 bug 的根因均为 commit 5b5291c 引入的回归:

Bug 1 (400 错误): _handle_llm_generate 直接调用 _prompt_template.render()
返回空 messages 列表,未尊重 portal 通过 task.input_data["messages"] 传入
的预构建消息契约。改为调用 _build_llm_messages(task)。

Bug 2 (工具不执行): default agent 用 AgentConfig(无 _skill_config),
handle_task_stream 落入 _handle_llm_generate 分支(只生成文本不执行工具)。
改为 SkillConfig(execution_mode="react", max_steps=10),走 ReAct 循环。

Bug 3 (对话列表报错记录反复出现): 核心根因是测试污染生产数据库。
test_portal_routes.py 的 app fixture 未覆盖模块级全局 _conversation_store,
TestPortalChat 通过 TestClient 调 /portal/chat 直接写入生产 SQLite;
mock_llm_gateway 的 AsyncMock chat_stream 返回 coroutine 触发 TypeError,
portal 把 "执行出错: ..." 作为 assistant 消息持久化。用户每次运行 pytest
后启动服务器都会看到新的报错对话。

修复:
- app fixture 用 monkeypatch + tmp_path 隔离 _conversation_store + 重建
  _sm_adapter
- mock_llm_gateway 增加 chat_stream async generator 使 ReAct 路径成功
- REST/SSE/WebSocket 三条路径异常时不持久化错误消息,新创建的空对话
  直接删除避免"半截"残留
- 新增回归测试 test_chat_error_does_not_persist_error_message
- 清理 39 条历史污染数据(data/conversations.db 已 gitignore)

验证: test_portal_routes.py 28 passed, test_config_driven.py 43 passed,
ruff check + format 通过, 生产数据库 "执行出错" 消息数 0→0(隔离生效)。
2026-07-07 01:05:53 +08:00
..
documents feat(documents): add document processing capability (U1-U9) 2026-06-23 15:05:01 +08:00
e2e refactor: remove all emoji from source code (#20) 2026-07-03 02:46:40 +08:00
integration fix(review): apply ce-code-review findings 2026-06-30 12:42:15 +08:00
manual test(u6): add L4 real-LLM smoke test for ReAct tool-use prompt 2026-07-02 22:08:45 +08:00
routes feat(documents): add document processing capability (U1-U9) 2026-06-23 15:05:01 +08:00
tools feat(documents): add document processing capability (U1-U9) 2026-06-23 15:05:01 +08:00
unit fix(portal/chat): 修复 400 错误 + 工具不执行 + 对话列表报错记录反复出现 2026-07-07 01:05:53 +08:00
__init__.py feat: initial fischer-agentkit package with unified agent architecture 2026-06-04 22:24:06 +08:00
conftest.py fix: 私董会数据持久化修复 + emoji 移除计划 2026-07-02 01:07:12 +08:00
test_routing_chain.py feat: accumulated frontend enhancements, docs, and static assets 2026-06-14 16:35:01 +08:00