3 个审查代理(复用/质量/效率)发现 15 个问题,全部修复: 效率与安全(6 项): - MCPClient 缓存 MultiServerMCPClient 单例 + aclose(),修复连接/子进程泄漏 - _rate_limits 清理空 IP 条目,修复 X-Forwarded-For 欺骗下内存泄漏 - _seen_nonces 改用 OrderedDict,O(1) 摊销过期清理 - webhook 后台任务加 Semaphore(20) + 任务引用追踪,限制无界并发 - _build_adapter 用 asyncio.gather 并行解密 secrets - 适配器实例缓存(_adapter_cache),token TTL 缓存跨请求命中 去重(4 项): - header_get 提取到 channels/base.py,4 个适配器统一 import - _get_client/close() 移入 MessageAdapter 基类,子类继承 - URLVerificationChallenge 统一到 base.py,feishu/slack/wecom 共用 - Transport ABC 添加 endpoint_url 属性,from_transport 不再访问私有字段 死代码与类型安全(5 项): - detect_cache_hit 死方法替换为 record_cache_result 公开 API - execution_mode.value == "direct_chat" 改用枚举比较 - 删除 yielded_any 死变量、重复 from fastapi import Request、 多余 getattr 防御 453 tests passed, ruff clean(预存 F841 非本次引入) |
||
|---|---|---|
| .. | ||
| documents | ||
| e2e | ||
| integration | ||
| routes | ||
| tools | ||
| unit | ||
| __init__.py | ||
| conftest.py | ||
| test_routing_chain.py | ||