AgentScope Code Review
Conduct a strict code review for the AgentScope agent-oriented programming framework. Each requirement is labeled with priority that determines whether changes are mandatory or recommended.
Priority Levels
**[MUST]** - Must be satisfied or PR will be rejected**[SHOULD]** - Strongly recommended**[MAY]** - Optional suggestionReview Instructions
When reviewing code changes, systematically check each section below and provide clear feedback organized by priority level.
1. Code Quality
**[MUST] Lazy Loading:**
Verify third-party library dependencies are imported at point of use, not centralized at file topThird-party libraries are those NOT in the `dependencies` variable in `pyproject.toml`For base class imports, ensure factory pattern is used:```python
def get_xxx_cls() -> "MyClass":
from xxx import BaseClass
class MyClass(BaseClass): ...
return MyClass
```
Flag any violations and suggest the correct lazy loading approach**[SHOULD] Code Conciseness:**
After understanding code intent, identify optimization opportunities: - Unnecessary temporary variables
- Duplicate code blocks that should be merged
- Cases where existing utility functions should be reused instead
Suggest specific refactoring improvements**[MUST] Encapsulation Standards:**
Verify all Python files under `src/agentscope` are named with `_` prefixCheck that exposure is controlled through `__init__.py`Ensure internal classes/functions not meant for users have `_` prefixFlag any violations of these naming conventions2. Code Security
**[MUST] Security Checks:**
Scan for hardcoded API keys, tokens, or passwordsVerify sensitive data uses environment variables or configuration filesCheck for exposed debug information or temporary credentialsIdentify injection attack risks (SQL injection, command injection, code injection, etc.)Require fixes for any security issues found3. Testing & Dependencies
**[MUST] Testing Requirements:**
Verify new features include unit testsCheck test coverage is adequate for new functionalityFlag missing tests**[MUST] Dependency Management:**
Verify new dependencies are added to appropriate section in `pyproject.toml`Ensure non-core scenario dependencies are NOT in minimal dependency listFlag improperly categorized dependencies4. Code Standards
**[MUST] Comment Standards:**
All comments and docstrings MUST be in EnglishVerify all classes and methods have complete docstrings following this template:```python
def func(a: str, b: int | None = None) -> str:
"""{description}
Args:
a (`str`):
The argument a
b (`int | None`, optional):
The argument b
Returns:
`str`:
The return str
"""
```
Check for reStructuredText syntax for special content:```python
class MyClass:
"""xxx
`Example link <https://xxx>`_
.. note:: Example note
.. tip:: Example tip
.. important:: Example important info
.. code-block:: python
def hello_world():
print("Hello world!")
"""
```
Flag incomplete or incorrectly formatted docstrings**[MUST] Pre-commit Checks:**
In most cases, code should be modified rather than skipping checksFile-level check skipping is PROHIBITEDOnly allowed skip: agent class system prompt parameters (to avoid `\n` formatting issues)Flag any inappropriate check skips5. Git Standards
**[MUST] PR Title Format:**
Verify title follows Conventional CommitsMust use prefixes: `feat`, `fix`, `docs`, `ci`, `refactor`, `test`, etc.Format: `<type>(scope): <description>`Example: `feat(memory): add redis cache support`Require correction if format is incorrectOutput Format
Organize your review feedback by priority:
1. **[MUST] Issues** - List all blocking issues that must be fixed
2. **[SHOULD] Recommendations** - List strongly recommended improvements
3. **[MAY] Suggestions** - List optional enhancements
4. **Summary** - Overall assessment and next steps
For each issue, provide:
File path and line number referenceClear explanation of the problemSpecific fix recommendation or code example