-
Notifications
You must be signed in to change notification settings - Fork 243
Fix blockbuster failing on blocking calls inside Agent.__init__ #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
plugins/aws/tests/test_aws.py (2)
30-32: Avoidhasattrandgetattrper coding guidelines.The coding guidelines explicitly state to avoid using
hasattr,getattr,delattr, andsetattr. Consider using normal attribute access with a try/except or checking forresponse.exception is Nonedirectly if the attribute is always expected.- assert not hasattr(response, "exception") or response.exception is None, ( - f"Response should not have an exception, got: {getattr(response, 'exception', None)}" - ) + assert response.exception is None, ( + f"Response should not have an exception, got: {response.exception}" + )Based on coding guidelines, prefer normal attribute access over
hasattr/getattr.
41-41: Remove redundant@pytest.mark.asynciodecorators.Per coding guidelines,
@pytest.mark.asynciois not needed as it's automatic. This applies to multiple tests in this file (lines 41, 49, etc.).plugins/gemini/tests/test_gemini_llm.py (1)
47-47: Avoidhasattrper coding guidelines.Consider using normal attribute access instead of
hasattr(response.original, "text").- assert hasattr(response.original, "text") # Gemini response has text attribute + assert response.original.text is not None # Gemini response has text attributeBased on coding guidelines, prefer normal attribute access.
conftest.py (1)
63-63: Path construction may be fragile.The path
agent_cls_fileis constructed by replacing.with/and appending.py. This assumes the module maps directly to a file path, which may break if the package structure changes or uses namespace packages.Consider using
inspect.getfile(Agent)for a more robust approach:import inspect agent_cls_file = inspect.getfile(Agent)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
agents-core/vision_agents/core/llm/llm.py(1 hunks)conftest.py(2 hunks)plugins/aws/tests/test_aws.py(1 hunks)plugins/aws/tests/test_aws_realtime.py(2 hunks)plugins/gemini/tests/test_gemini_llm.py(1 hunks)plugins/openai/tests/test_openai_realtime.py(1 hunks)plugins/openai/vision_agents/plugins/openai/openai_realtime.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*test*.py
📄 CodeRabbit inference engine (.cursor/rules/python.mdc)
**/*test*.py: Never mock in tests; use pytest for testing
Mark integration tests with @pytest.mark.integration decorator
@pytest.mark.asyncio is not needed - it is automatic
Files:
plugins/gemini/tests/test_gemini_llm.pyplugins/aws/tests/test_aws_realtime.pyplugins/aws/tests/test_aws.pyplugins/openai/tests/test_openai_realtime.pyconftest.py
**/*.py
📄 CodeRabbit inference engine (.cursor/rules/python.mdc)
**/*.py: Never adjust sys.path in Python code
Never writeexcept Exception as e- use specific exception handling
Avoid using getattr, hasattr, delattr and setattr; prefer normal attribute access in Python
Docstrings should follow the Google style guide for docstrings
Files:
plugins/gemini/tests/test_gemini_llm.pyplugins/openai/vision_agents/plugins/openai/openai_realtime.pyplugins/aws/tests/test_aws_realtime.pyplugins/aws/tests/test_aws.pyagents-core/vision_agents/core/llm/llm.pyplugins/openai/tests/test_openai_realtime.pyconftest.py
🧬 Code graph analysis (6)
plugins/gemini/tests/test_gemini_llm.py (2)
agents-core/vision_agents/core/llm/llm.py (1)
set_instructions(179-193)plugins/openai/vision_agents/plugins/openai/openai_realtime.py (1)
set_instructions(471-473)
plugins/openai/vision_agents/plugins/openai/openai_realtime.py (2)
agents-core/vision_agents/core/llm/llm.py (1)
set_instructions(179-193)agents-core/vision_agents/core/instructions.py (1)
Instructions(15-115)
plugins/aws/tests/test_aws_realtime.py (4)
plugins/openai/tests/test_openai_realtime.py (1)
realtime(20-30)plugins/gemini/tests/test_gemini_realtime.py (1)
realtime(15-23)agents-core/vision_agents/core/llm/llm.py (1)
set_instructions(179-193)plugins/openai/vision_agents/plugins/openai/openai_realtime.py (1)
set_instructions(471-473)
plugins/aws/tests/test_aws.py (2)
agents-core/vision_agents/core/llm/llm.py (1)
set_instructions(179-193)plugins/openai/vision_agents/plugins/openai/openai_realtime.py (1)
set_instructions(471-473)
agents-core/vision_agents/core/llm/llm.py (2)
plugins/openai/vision_agents/plugins/openai/openai_realtime.py (1)
set_instructions(471-473)agents-core/vision_agents/core/instructions.py (1)
Instructions(15-115)
plugins/openai/tests/test_openai_realtime.py (4)
plugins/aws/tests/test_aws_realtime.py (1)
realtime(20-31)plugins/gemini/tests/test_gemini_realtime.py (1)
realtime(15-23)agents-core/vision_agents/core/llm/llm.py (1)
set_instructions(179-193)plugins/openai/vision_agents/plugins/openai/openai_realtime.py (1)
set_instructions(471-473)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: unit / Mypy
- GitHub Check: unit / Test "not integration"
🔇 Additional comments (9)
plugins/aws/tests/test_aws.py (1)
149-149: LGTM!The change to pass a plain string to
set_instructionsaligns with the updated API that now acceptsInstructions | str.plugins/gemini/tests/test_gemini_llm.py (1)
87-87: LGTM!The change to pass a plain string to
set_instructionsis consistent with the updated API across the codebase.plugins/aws/tests/test_aws_realtime.py (2)
27-27: LGTM!The fixture now passes a plain string to
set_instructions, consistent with the updated API.
37-39: LGTM!Consistent usage of the string-based
set_instructionsAPI within the test.agents-core/vision_agents/core/llm/llm.py (2)
179-193: LGTM!The implementation correctly handles both
strandInstructionstypes with proper type dispatch. The docstring follows Google style, and theTypeErrorprovides a clear message for invalid inputs. This is the core change that enables the API flexibility across all plugins.
186-189: The review comment is not applicable—None is not a valid use case.The method's type signature explicitly specifies
instructions: Instructions | str, excludingNone. TheAgentclass always provides a non-None string default, and no callers in the codebase passNonetoset_instructions. The current implementation correctly raises aTypeErrorfor invalid types, which is consistent with the explicit type contract. IfNonewere to become a valid input in the future, the type signature would need to be updated toOptional[Instructions | str], but there is no evidence or requirement for this.conftest.py (1)
59-68: The review comment is incorrect —bb.functionsis the correct attribute name and the code is properly implemented.The BlockBuster library (version ≥1.5.5,<1.6) exposes a
.functionsdict that maps blocking function names toBlockBusterFunctioninstances. EachBlockBusterFunctionhas acan_block_in()method, which is correctly called in the code at line 67. The original concern referencingBlockBuster.bbappears to be based on a misunderstanding of the library's API. The implementation is correct as written.plugins/openai/vision_agents/plugins/openai/openai_realtime.py (1)
471-473: Override correctly mirrors core LLM.set_instructions behaviorThe widened
Instructions | strsignature and delegation tosuper().set_instructionskeep the type logic centralized while ensuringrealtime_session["instructions"]is always the resolved string (self._instructions). This is consistent withvision_agents.core.llm.llm.LLM.set_instructionsand looks correct.plugins/openai/tests/test_openai_realtime.py (1)
19-30: Test fixture correctly uses string-based instructions APICalling
realtime.set_instructions("be friendly")aligns this integration test with the updatedset_instructions(Instructions | str)API and avoids unnecessaryInstructionsconstruction in the fixture. Looks good.
BlockBusterfails some integration tests becauseInstructionsobject parses markdown files on__init__in a blocking way.Making it non-blocking would be more clunky and require more code, and it's ok for
Instructions.__init__to be blocking since it's created once and before any async work.So the solution is:
Agent.__init__.LLM.set_instructions()to accept plainstr.Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.