AgentScope Code Review
Conduct a strict code review for AgentScope, an agent-oriented programming framework for building LLM applications. Each requirement is labeled with priority:
**[MUST]** must be satisfied or PR will be rejected**[SHOULD]** strongly recommended**[MAY]** optional suggestionInstructions
Follow these steps when reviewing code:
1. Code Quality Review
#### [MUST] Verify Lazy Loading
Check that third-party library dependencies (libraries not in `pyproject.toml` `dependencies`) are imported at point of use, not at file topFor base class imports, verify factory pattern usage:```python
def get_xxx_cls() -> "MyClass":
from xxx import BaseClass
class MyClass(BaseClass): ...
return MyClass
```
Flag any centralized imports of optional dependencies#### [SHOULD] Check Code Conciseness
After understanding code intent, identify optimization opportunities:
Remove unnecessary temporary variablesMerge duplicate code blocksSuggest reusing existing utility functions#### [MUST] Verify Encapsulation Standards
Confirm all Python files under `src/agentscope` use `_` prefix and are exposed through `__init__.py`Verify internal classes/functions have `_` prefix if not meant for user exposure2. [MUST] Security Audit
Check for security issues:
No hardcoded API keys, tokens, or passwordsCredentials managed via environment variables or config filesNo debug information or temporary credentials in codeNo injection attack risks (SQL/command/code injection)3. [MUST] Testing & Dependencies
Verify:
New features include unit testsNew dependencies added to appropriate `pyproject.toml` sectionNon-core dependencies not added to minimal dependency list4. [MUST] Code Standards Compliance
#### Documentation Requirements
**All comments and documentation in English**Every class and method has 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
"""
```
Special content uses reStructuredText syntax:```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!")
"""
```
#### Pre-commit Check Compliance
**Code should be modified to pass checks, not skipped**File-level check skipping is prohibitedOnly allowed skip: agent class system prompt parameters (to avoid `\n` formatting issues)5. [MUST] Git Standards
#### PR Title Format
Must follow Conventional CommitsRequired prefixes: `feat/fix/docs/ci/refactor/test`Format: `feat(scope): description`Example: `feat(memory): add redis cache support`Review Output
Provide feedback organized by priority:
1. **[MUST]** violations that block PR approval
2. **[SHOULD]** strong recommendations
3. **[MAY]** optional suggestions
For each issue found, specify:
File and line numberWhat the issue isHow to fix itWhy it mattersNotes
AgentScope is a Python framework for building LLM-based agent applicationsThe codebase emphasizes modularity through lazy loading to minimize dependenciesSecurity and testing are non-negotiable requirementsDocumentation quality directly impacts user experience