feat(v3): T27 会话式智能体(多轮上下文/停止/对话式 UI,对齐 dsh 范式)
- ToolLoop 增 history 参数(既往轮次折叠为对话上下文,近 6 轮)
- 会话制:AgentSession/SessionStore 持久化 agent_runs/sessions/{sid}.json,
/agent/sessions CRUD + /agent 带 session_id(继承会话工作区与执行者配置,busy 并发控制)
- POST /agent/{id}/cancel:取消运行中任务
- AgentView 重构为对话式:会话列表 + 居中消息流(用户蓝气泡/助手白卡)+ 底部 composer
(工作区/执行者/命令 chips,Enter 发送,运行中红色停止钮),工具过程折叠收纳
- 工具步数统计统一至事件写入层并透出 status.tool_calls
- fix(tests): 会话存储测试隔离,防测试数据泄漏进真实 sessions 目录
- 测试 +4,全量 281 passed
This commit is contained in:
@@ -237,3 +237,17 @@ def test_browse_directories(tmp_path):
|
||||
assert r["ok"] is True and r["dirs"] == ["sub"] # 只列目录不列文件
|
||||
assert r["parent"] # 可以上级
|
||||
assert browse_directories(str(tmp_path / "ghost"))["ok"] is False
|
||||
|
||||
|
||||
def test_toolloop_history_injected(ws):
|
||||
"""history 应出现在 system 之后、任务之前(会话式多轮上下文)。"""
|
||||
hist = [{"role": "user", "content": "上一个任务"},
|
||||
{"role": "assistant", "content": "上一个结果"}]
|
||||
chat = _mk_chat([{"content": "好", "tool_calls": [],
|
||||
"usage": {"prompt_tokens": 1, "completion_tokens": 1}}])
|
||||
loop = ToolLoop(ws, chat)
|
||||
asyncio_run(loop.run("新任务", system="SYS", history=hist))
|
||||
msgs = chat.calls[0]
|
||||
assert msgs[0] == {"role": "system", "content": "SYS"}
|
||||
assert msgs[1:3] == hist
|
||||
assert msgs[3] == {"role": "user", "content": "新任务"}
|
||||
|
||||
Reference in New Issue
Block a user