sync update from LAN repo (source master @ ca48c4ec)

This commit is contained in:
gozeros committed 2026-11-05 10:53:54 +08:00
1 parent 8bc8b0e082
commit ea9dcff9c0
873 files changed
+107866 -14011

No files matched your search

@@ -41,11 +41,21 @@ class _RecGateway:
def __init__(self, dispatch_cycles: list[list[tuple[str, str]]]) -> None:
self._cycles = dispatch_cycles
self._leader_calls = 0
self.leader_requests: list[tuple[str, bool]] = []
self.seat_tasks: list[tuple[str, str]] = []
self.active = 0
self.max_active = 0
async def run_leader(self, *, thread_ids, coordinator_name, message, model) -> LeaderTurn:
async def run_leader(
self,
*,
thread_ids,
coordinator_name,
message,
model,
finalize_only: bool = False,
) -> LeaderTurn:
self.leader_requests.append((message, finalize_only))
i = self._leader_calls
self._leader_calls += 1
disp = self._cycles[i] if i < len(self._cycles) else []
@@ -64,7 +74,7 @@ class _RecGateway:
raise AssertionError("enable_report=False 不应绘制报告")
async def _run(gw: _RecGateway, *, gather_first: bool):
async def _run(gw: _RecGateway, *, gather_first: bool, max_cycles: int = 8):
return await run_orchestration(
gateway=gw,
progress=_writer(),
@@ -77,6 +87,7 @@ async def _run(gw: _RecGateway, *, gather_first: bool):
intent_text="背景X",
enable_report=False,
gather_first=gather_first,
max_cycles=max_cycles,
)
@@ -138,3 +149,33 @@ async def test_gather_phase_is_parallel():
assert all(_GATHER_MARK in t for _, t in gw.seat_tasks)
assert len(gw.seat_tasks) == 3
assert gw.max_active == 3 # 取数阶段三席位真并行
@pytest.mark.asyncio
async def test_recommend_eighth_round_forces_text_closeout_instead_of_stopping():
"""前 7 轮仍派活时,第 8 轮必须关闭工具并要求总控总结,不能直接停止。"""
gw = _RecGateway([[('seat-a', f'task-{i}')] for i in range(8)])
result = await _run(gw, gather_first=False)
assert result.status == "done"
assert result.consensus is True
assert len(gw.leader_requests) == 8
assert [finalize for _, finalize in gw.leader_requests] == [False] * 7 + [True]
assert "最终方案与结论正文" in gw.leader_requests[-1][0]
assert "不要调用任何工具" in gw.leader_requests[-1][0]
# 第 8 轮是总控收口,不再执行假网关返回的派活。
assert len(gw.seat_tasks) == 7
@pytest.mark.asyncio
async def test_recommend_uses_configured_closeout_round():
"""动态配置第 3 轮收口时,只执行前两轮席位派活。"""
gw = _RecGateway([[('seat-a', f'task-{i}')] for i in range(4)])
result = await _run(gw, gather_first=False, max_cycles=3)
assert result.status == "done"
assert len(gw.leader_requests) == 3
assert [finalize for _, finalize in gw.leader_requests] == [False, False, True]
assert len(gw.seat_tasks) == 2