fischer-agentkit/tests/unit/experts
Chiguyong ed1e289785 fix(board): add first-chunk timeout to _stream_expert_speech
Commit 36b0296 changed expert speech generation from gateway.chat()
(non-streaming) to gateway.chat_stream() (streaming) for progressive
UI output. However, DashScope/DeepSeek via LiteLLM occasionally accept
the streaming request but never emit the first SSE chunk — the async
generator hangs indefinitely with no error and no timeout, freezing
the entire board.

Root cause: `async for chunk in gateway.chat_stream(...)` blocks
forever when the provider silently stalls. The moderator path
(gateway.chat) still works because it's synchronous — that's why
the moderator opening always succeeds but experts hang.

Fix: pull the first chunk via `__anext__()` wrapped in
`asyncio.wait_for(timeout=30s)`. If no chunk arrives within 30s,
close the stream and fall back to non-streaming gateway.chat() +
_replay_stream() (which splits the response into small chunks for
progressive UI rendering). This preserves the "逐个输出" UX while
guaranteeing the board never hangs on a stalled streaming provider.

Add 4 unit tests covering:
- Normal streaming works (existing path)
- First-chunk timeout → fallback to chat()
- Empty stream → fallback to chat()
- chat_stream raising → fallback to chat()

E2E verification: 5-expert board with DashScope completes in ~277s
(status=completed), all experts produce content, no hang.

Same branch as the earlier _handle_llm_gateway fix (commit d0fe661).
2026-07-06 15:35:15 +08:00
..
__init__.py feat: Expert Team Mode — plan-execute collaboration with conversation UI 2026-06-14 22:20:14 +08:00
_helpers.py test: fix async generator mock for U3 streaming orchestrator 2026-07-02 22:52:10 +08:00
test_board_backtest.py feat: 私董会讨论模式 + 回测集成 + WS持久化修复 2026-06-17 23:52:53 +08:00
test_board_orchestrator.py fix(board): add first-chunk timeout to _stream_expert_speech 2026-07-06 15:35:15 +08:00
test_board_router.py feat: 企业级客户端-服务端架构 + 代码审查修复 2026-06-20 06:48:18 +08:00
test_board_team.py refactor: remove all emoji from agentkit 2026-07-02 01:33:28 +08:00
test_config.py refactor: remove all emoji from agentkit 2026-07-02 01:33:28 +08:00
test_divergence_detection.py feat(experts): U3 分歧检测 + 方案评审辩论自动触发 2026-06-24 11:09:53 +08:00
test_expert.py refactor: remove all emoji from agentkit 2026-07-02 01:33:28 +08:00
test_orchestrator_debate.py feat(experts): U4 用户干预通道 + 手动辩论触发 2026-06-24 12:17:09 +08:00
test_phase_executor_streaming.py fix(experts): resolve residual review findings from PR #13 2026-07-01 13:26:19 +08:00
test_plan.py feat(experts): U1 协作契约数据模型 + Lead 生成契约 2026-06-24 13:44:50 +08:00
test_pm_collaboration.py test: fix async generator mock for U3 streaming orchestrator 2026-07-02 22:52:10 +08:00
test_registry.py refactor: remove all emoji from agentkit 2026-07-02 01:33:28 +08:00
test_router.py feat(experts): U7 新增 5 个编程专家模板 + dev_team 团队模板 + ExpertTeamRouter 模板展开 2026-06-18 01:50:43 +08:00
test_team.py feat(experts):重写 TeamOrchestrator 为流水线模式 + TeamStatus.PLANNING 2026-06-18 01:39:22 +08:00
test_team_intervention.py feat(experts): U4 用户干预通道 + 手动辩论触发 2026-06-24 12:17:09 +08:00
test_team_orchestrator.py fix(bitable/team): U3 — Residual P2 findings (DR-1/3/4/5 + #2/#3) 2026-07-06 03:48:14 +08:00