-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
docs: standardize Context class documentation formatting #4436
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
docs: standardize Context class documentation formatting #4436
Conversation
- Unified all method docstrings to standard format - Fixed mixed language and formatting issues - Added complete parameter and return descriptions - Enhanced developer experience for plugin creators - Fixes AstrBotDevs#4429
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.
Hey - 我发现了两个问题,并给出了一些总体层面的反馈:
- 一些公共 SDK 方法之前使用了 Sphinx 指令,例如
.. versionadded:: 4.5.7 (sdk),现在被转换成了普通的文本说明;如果这些内容会被网站端的 Sphinx/autodoc 使用,建议保留原来的指令格式,以免破坏文档的渲染效果。 - 废弃标记被统一成了叙述式的
Note段落(例如[DEPRECATED]→该方法已弃用);请再次确认项目偏好的废弃标注风格,并让这些 docstring 与现有的模式或装饰器保持一致,这样工具和用户才能一致地检测到已废弃的 API。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Several public SDK methods previously used Sphinx directives like `.. versionadded:: 4.5.7 (sdk)` which have been converted into plain text notes; if these are consumed by Sphinx/autodoc for the website, consider keeping the directive format to avoid breaking the rendered docs.
- The deprecation markers were normalized into narrative `Note` sections (e.g. `[DEPRECATED]` → `该方法已弃用`); double-check the project’s preferred deprecation style and align these docstrings with any existing patterns or decorators so that tooling and users can consistently detect deprecated APIs.
## Individual Comments
### Comment 1
<location> `astrbot/core/star/context.py:164` </location>
<code_context>
async def tool_loop_agent(
</code_context>
<issue_to_address>
**issue (bug_risk):** Clarify how **kwargs are propagated (to agent runner vs directly to the LLM) to avoid misuse.
The previous docstring made it clear that `**kwargs` are handled by the agent runner (e.g., `stream`, `agent_hooks`, `agent_context`, and other `runner.reset()` args) and are not passed through to the LLM. The new Chinese docstring lists params but omits this, which could mislead users into thinking arbitrary kwargs are forwarded to the LLM API. Please reintroduce a brief note that `**kwargs` are consumed by the agent loop/runner rather than transparently sent to the LLM.
</issue_to_address>
### Comment 2
<location> `astrbot/core/star/context.py:122-126` </location>
<code_context>
+ ChatProviderNotFoundError: 指定的聊天提供者 ID 未找到。
+ Exception: LLM 生成过程中的其他错误。
+
+ Note:
+ 版本 4.5.7 新增。
"""
</code_context>
<issue_to_address>
**nitpick (typo):** Typo in `MessageSesion` type name in the note.
This appears to be a misspelling of `MessageSession` (missing the second "s"), which could confuse readers searching for the type. Please correct the spelling for clarity in the docs.
Suggested implementation:
```python
MessageSession
```
If `MessageSesion` is also used elsewhere in this file (for example, in other docstrings, comments, or type hints), the same replacement to `MessageSession` should be applied there as well to keep everything consistent.
</issue_to_address>Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Original comment in English
Hey - I've found 2 issues, and left some high level feedback:
- Several public SDK methods previously used Sphinx directives like
.. versionadded:: 4.5.7 (sdk)which have been converted into plain text notes; if these are consumed by Sphinx/autodoc for the website, consider keeping the directive format to avoid breaking the rendered docs. - The deprecation markers were normalized into narrative
Notesections (e.g.[DEPRECATED]→该方法已弃用); double-check the project’s preferred deprecation style and align these docstrings with any existing patterns or decorators so that tooling and users can consistently detect deprecated APIs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Several public SDK methods previously used Sphinx directives like `.. versionadded:: 4.5.7 (sdk)` which have been converted into plain text notes; if these are consumed by Sphinx/autodoc for the website, consider keeping the directive format to avoid breaking the rendered docs.
- The deprecation markers were normalized into narrative `Note` sections (e.g. `[DEPRECATED]` → `该方法已弃用`); double-check the project’s preferred deprecation style and align these docstrings with any existing patterns or decorators so that tooling and users can consistently detect deprecated APIs.
## Individual Comments
### Comment 1
<location> `astrbot/core/star/context.py:164` </location>
<code_context>
async def tool_loop_agent(
</code_context>
<issue_to_address>
**issue (bug_risk):** Clarify how **kwargs are propagated (to agent runner vs directly to the LLM) to avoid misuse.
The previous docstring made it clear that `**kwargs` are handled by the agent runner (e.g., `stream`, `agent_hooks`, `agent_context`, and other `runner.reset()` args) and are not passed through to the LLM. The new Chinese docstring lists params but omits this, which could mislead users into thinking arbitrary kwargs are forwarded to the LLM API. Please reintroduce a brief note that `**kwargs` are consumed by the agent loop/runner rather than transparently sent to the LLM.
</issue_to_address>
### Comment 2
<location> `astrbot/core/star/context.py:122-126` </location>
<code_context>
+ ChatProviderNotFoundError: 指定的聊天提供者 ID 未找到。
+ Exception: LLM 生成过程中的其他错误。
+
+ Note:
+ 版本 4.5.7 新增。
"""
</code_context>
<issue_to_address>
**nitpick (typo):** Typo in `MessageSesion` type name in the note.
This appears to be a misspelling of `MessageSession` (missing the second "s"), which could confuse readers searching for the type. Please correct the spelling for clarity in the docs.
Suggested implementation:
```python
MessageSession
```
If `MessageSesion` is also used elsewhere in this file (for example, in other docstrings, comments, or type hints), the same replacement to `MessageSession` should be applied there as well to keep everything consistent.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
from astrbot.core.platform.astr_message_event import AstrMessageEvent, MessageSesion |
- Restored Sphinx directives for versionadded notes - Fixed MessageSesion typo to MessageSession throughout file - Added clarification for kwargs propagation in tool_loop_agent - Unified deprecation marker format - Fixes AstrBotDevs#4429
对的,当然 MessageSession 也是对的,MessageSesion 是其 alias。 |
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.
需要将注释更改为英文。
已经修改 |
* docs: standardize Context class documentation formatting - Unified all method docstrings to standard format - Fixed mixed language and formatting issues - Added complete parameter and return descriptions - Enhanced developer experience for plugin creators - Fixes #4429 * docs: fix Context class documentation issues per review - Restored Sphinx directives for versionadded notes - Fixed MessageSesion typo to MessageSession throughout file - Added clarification for kwargs propagation in tool_loop_agent - Unified deprecation marker format - Fixes #4429 * Convert developer API comments to English * chore: revise comments --------- Co-authored-by: Soulter <[email protected]>
* stage * fix: update tool call logging to include tool call IDs and enhance sandbox ship creation parameters * feat: file upload * fix * update * fix: remove 'boxlite' option from booter and handle error in PythonTool execution * feat: implement singleton pattern for ShipyardSandboxClient and add FileUploadTool for file uploads * feat: sandbox * fix * beta * uv lock * remove * chore: makes world better * feat: implement localStorage persistence for showReservedPlugins state * docs: refine EULA * fix * feat: add availability check for sandbox in Shipyard and base booters * feat: add shipyard session configuration options and update related tools * feat: add file download functionality and update shipyard SDK version * fix: sending OpenAI-style image_url causes Anthropic 400 invalid tag error (#4444) * feat: chatui project (#4477) * feat: chatui-project * fix: remove console log from getProjects function * fix: title saving logic and update project sessions on changes * docs: standardize Context class documentation formatting (#4436) * docs: standardize Context class documentation formatting - Unified all method docstrings to standard format - Fixed mixed language and formatting issues - Added complete parameter and return descriptions - Enhanced developer experience for plugin creators - Fixes #4429 * docs: fix Context class documentation issues per review - Restored Sphinx directives for versionadded notes - Fixed MessageSesion typo to MessageSession throughout file - Added clarification for kwargs propagation in tool_loop_agent - Unified deprecation marker format - Fixes #4429 * Convert developer API comments to English * chore: revise comments --------- Co-authored-by: Soulter <[email protected]> * fix: handle empty output case in PythonTool execution * fix: update description for command parameter in ExecuteShellTool * refactor: remove unused file tools and update PythonTool output handling * project list * fix: ensure message stream order (#4487) * feat: enhance iPython tool rendering with Shiki syntax highlighting * bugfixes * feat: add sandbox mode prompt for enhanced user guidance in executing commands * chore: remove skills prompt --------- Co-authored-by: 時壹 <[email protected]> Co-authored-by: Li-shi-ling <[email protected]>
Fixes #4429:改进Context类的代码注释,解决语言不统一、格式不统一的问题,提高插件开发者的使用体验。
Modifications / 改动点
修改了
astrbot/core/star/context.py文件中的Context类文档字符串:@param和标准格式)@param、@return等非标准格式Screenshots or Test Results / 运行截图或测试结果
代码规范检查通过:
能够正常运行astrbot

Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.额外说明
Summary by Sourcery
标准化并丰富
Context类的文档,以提升针对插件和 SDK 用户的清晰度和一致性。文档更新:
Context方法的文档字符串风格,将原先混杂的格式替换为一致的参数化风格,并包含返回值和错误信息。Original summary in English
Summary by Sourcery
Standardize and enrich documentation for the Context class to improve clarity and consistency for plugin and SDK users.
Documentation: