Fix: OpenAI LLM test memory exhaustion during collection#3291
Merged
Conversation
Contributor
🔍 Code Review Comments1. [代码规范] 模块初始化逻辑缺失 2. [逻辑漏洞] 测试覆盖有效性 |
YehongPan
reviewed
Jun 24, 2026
YehongPan
left a comment
Contributor
There was a problem hiding this comment.
Code Review
- [代码规范] 删除了
spec.loader.exec_module的 try/except 块但没有补充替代的模块初始化逻辑,后续如果OpenAIModel需要在此测试文件中使用,将始终为None。 - [逻辑漏洞] 注释说明"importing it twice can initialise the real monitoring stack",应确认这是否意味着该测试文件中的测试用例全部跳过了实际功能验证,降低了测试价值。
JasonW404
commented
Jun 24, 2026
WMC001
approved these changes
Jun 24, 2026
Contributor
|
Bug: test passes removed parameter In test/backend/utils/test_context_utils.py, test_kb_not_duplicated_in_tools calls build_tools_component with knowledge_base_summary='KB text', but this parameter was removed from _format_tools_description in this PR. The test will fail at runtime with TypeError: unexpected keyword argument. Fix: remove knowledge_base_summary from the test call, or drop the test entirely. |
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.
Problem
test/sdk/core/models/test_openai_llm.pywas callingspec.loader.exec_module()at module level during test collection. This triggered a second import ofopenai_llmbefore the full mock graph was installed, which initialised the real monitoring stack and exhausted local resources (memory).Fix
Remove the premature
exec_module()call and its try/except cleanup. Instead, defer the import to the test body where the mock graph is fully in place.OpenAIModelis set toNoneat module level and resolved lazily.Changes
test/sdk/core/models/test_openai_llm.py— removed 10 lines of eager module execution, added explanatory comment (4 lines)