Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
astrbot-docs | b7df91d | Commit Preview URL Branch Preview URL |
Jul 05 2026, 03:02 AM |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider guarding
_sanitize_malformed_tool_callsagainstllm_resp.tools_call_namebeingNoneor a non-list to avoid runtime errors when the LLM returns unexpected structures. - If
MALFORMED_TOOL_NAME_PLACEHOLDERmight surface in user-facing logs or messages, consider making it more descriptive (e.g., including a brief explanation or prefix) so it's clear that the tool name was missing or malformed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding `_sanitize_malformed_tool_calls` against `llm_resp.tools_call_name` being `None` or a non-list to avoid runtime errors when the LLM returns unexpected structures.
- If `MALFORMED_TOOL_NAME_PLACEHOLDER` might surface in user-facing logs or messages, consider making it more descriptive (e.g., including a brief explanation or prefix) so it's clear that the tool name was missing or malformed.
## Individual Comments
### Comment 1
<location path="astrbot/core/agent/runners/tool_loop_agent_runner.py" line_range="703-708" />
<code_context>
+ Args:
+ llm_resp: The LLM response whose tool call lists should be sanitized.
+ """
+ llm_resp.tools_call_name = [
+ self.MALFORMED_TOOL_NAME_PLACEHOLDER
+ if tool_name is None or tool_name == ""
+ else tool_name
+ for tool_name in llm_resp.tools_call_name
</code_context>
<issue_to_address>
**suggestion:** Consider treating whitespace-only tool names as malformed as well.
Right now `None` and `""` are normalized, but names like `" "` pass through. If whitespace-only names should also be considered malformed/empty, update the condition to use `strip()` (e.g. `if tool_name is None or tool_name.strip() == ""`).
```suggestion
llm_resp.tools_call_name = [
self.MALFORMED_TOOL_NAME_PLACEHOLDER
if tool_name is None or tool_name.strip() == ""
else tool_name
for tool_name in llm_resp.tools_call_name
]
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to sanitize malformed tool call names in LLM responses by replacing empty or null names with a placeholder (__malformed_tool_name__). This sanitization is applied during LLM response iteration and tool execution resolution (including requery and repair steps). The reviewer suggested enhancing this sanitization method to defensively handle None values and align the lengths of tools_call_name, tools_call_ids, and tools_call_args to prevent potential IndexError or silent truncation issues during processing.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
fixes: #8929
closes: #8911
Modifications / 改动点
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Enhancements: