GitHub Copilot Code Review
This skill conducts strict code reviews for the AgentScope project. Each requirement is labeled with priority:
**[MUST]** must be satisfied or PR will be rejected**[SHOULD]** strongly recommended**[MAY]** optional suggestionInstructions
When reviewing code for the AgentScope project, follow these guidelines systematically:
1. Code Quality Review
#### [MUST] Lazy Loading Check
Verify that third-party library dependencies are imported at the point of use, not at file top"Third-party library" means libraries 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 with severity: MUST FIX#### [SHOULD] Code Conciseness
After understanding code intent, check for optimization opportunities:
Identify unnecessary temporary variablesLook for duplicate code blocks that can be mergedSuggest reusing existing utility functions where applicableProvide specific refactoring suggestions#### [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 exposed to users) have `_` prefixFlag violations with severity: MUST FIX2. [MUST] Code Security Review
Check for security vulnerabilities:
Hardcoded API keys, tokens, or passwords (reject immediately)Verify secrets use environment variables or configuration filesIdentify debug information or temporary credentials left in codeCheck for injection attack risks: SQL injection, command injection, code injectionFlag any security issues with severity: CRITICAL3. [MUST] Testing & Dependencies Review
Verify new features include unit testsCheck that new dependencies are added to appropriate section in `pyproject.toml`Ensure dependencies for non-core scenarios are NOT in minimal dependency listFlag missing tests or incorrect dependency placement4. Code Standards Review
#### [MUST] Comment Standards
Verify all comments and docstrings are in **English**Check all classes/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
"""
```
For special content, verify reStructuredText syntax is used correctlyFlag incomplete or incorrectly formatted docstrings#### [MUST] Pre-commit Checks
In most cases, code should be modified rather than skipping checksFile-level check skipping is **prohibited**Only allowed skip: agent class system prompt parameters (to avoid `\n` formatting issues)Flag any inappropriate check skipping5. [MUST] Git Standards Review
#### PR Title Check
Verify PR follows Conventional Commits formatMust use prefixes: `feat`, `fix`, `docs`, `ci`, `refactor`, `test`, etc.Format must be: `prefix(scope): description`Example: `feat(memory): add redis cache support`Flag incorrect PR titles with required formatReview Output Format
Structure your review as follows:
1. **Summary**: Brief overview of changes
2. **Critical Issues [MUST]**: List all blocking issues that must be fixed
3. **Recommended Changes [SHOULD]**: Strongly recommended improvements
4. **Suggestions [MAY]**: Optional improvements
5. **Approval Status**: APPROVED / CHANGES REQUIRED
For each issue, provide:
File and line referenceSeverity level ([MUST]/[SHOULD]/[MAY])Clear explanation of the problemSpecific fix recommendation or code exampleExamples
**Bad - Lazy Loading Violation:**
```python
At top of file
from some_third_party_lib import SomeClass # MUST FIX: Import at point of use
```
**Good - Lazy Loading:**
```python
def my_function():
from some_third_party_lib import SomeClass # Imported at use point
return SomeClass()
```
**Bad - Missing Docstring:**
```python
def process_data(data): # MUST FIX: Missing docstring
return data.strip()
```
**Good - Complete Docstring:**
```python
def process_data(data: str) -> str:
"""Process the input data by removing whitespace.
Args:
data (`str`):
The input string to process
Returns:
`str`:
The processed string with whitespace removed
"""
return data.strip()
```