fix(ai): avoid quadratic coverage counting during analysis - #167
Merged
2977094657 merged 2 commits intoSep 28, 2026
Merged
Conversation
Member
|
有失败,修一下 |
Windows CI intermittently failed test_stream_waits_for_notification_ instead_of_polling...: the next frame after the event write was the ': heartbeat' comment, so parsing 'data: ' raised IndexError. A slow synchronous SQLite write can let the 30ms test heartbeat win the race; a heartbeat comment before an event frame is protocol-valid SSE, so keep production behavior and instead raise the heartbeat above the 0.5s assertion deadline for the notification check. A broken notification now fails with TimeoutError instead of passing on a heartbeat frame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题原因与表现
完整分析聊天时,程序会定期统计已有多少消息被分析。原来的数据库查询可能对每条消息反复扫描已保存的覆盖记录;记录越多,单次统计越慢,进而拖慢整个分析任务。这里增加的是本地等待时间,不会把旧消息重复发送给模型。
修复
验证
后续提交:修复 Windows CI 偶发失败(仅测试)
tests/test_ai_agent_sse.py在 Windows 上偶发IndexError——事件写入较慢时,30ms 的测试心跳帧先于事件帧到达,解析data:失败。TimeoutError失败,而不是靠心跳重查误判通过。