Skip to content

Fixed #8546 and also fixed #8552#8590

Closed
bytecategory wants to merge 10 commits into
AstrBotDevs:masterfrom
bytecategory:master
Closed

Fixed #8546 and also fixed #8552#8590
bytecategory wants to merge 10 commits into
AstrBotDevs:masterfrom
bytecategory:master

Conversation

@bytecategory
Copy link
Copy Markdown

@bytecategory bytecategory commented Jun 5, 2026

Fixed #8546 and also fixed #8552
Actually,
Fixed Pydantic data validation errors
Added validation for function.name being None and empty tool_call_id issues
In AstrBot/astrbot/core/computer/booters/local.py, a _BLOCKED_COMMAND_PATTERNS list was defined; users can now customize this list
Changed the health mode default to false — major mistake! Accidentally committed cmd_config.json! I won't change this config for now. If other collaborators (not contributors) request it, it can be modified.
After visiting http://X.X.X.X:6185/#/platforms and clicking "Create Bot" then selecting a messaging platform category, Telegram is placed at the very top — far ahead of others.
Regarding step limits and boring prompts (#8549), you can see the maximum step count is currently 30 — this is unreasonable and should be changed to 114514
Automatically apply for free Let's Encrypt SSL certificates, which means you can access it via https://X.X.X.X


修复了 #8546 也修复了 #8552

  • 修复了Pydantic数据验证错误
  • 做了function.name为None的校验 以及tool_call_id为空的问题
  • AstrBot/astrbot/core/computer/booters/local.py 里定义了一个_BLOCKED_COMMAND_PATTERNS 现在用户能自定义这个列表了
  • 把健康模式默认改成了false,重大失误! 一不小心把cmd_config.json提交了! 这个配置我暂时不改了,如果其他协作者(不是贡献者)要求可以改.
  • 访问http://X.X.X.X:6185/#/platforms 后点击创建机器人并选择消息平台类别时 Telegram被放到最前面 遥遥领先.
  • 关于步数的限制以及无聊的提示 #8549 这里可以看到最大步数是30步 这是不合理的 应该改成114514
  • 自动申请Lets encrypt的免费IP证书 这意味着你可以通过https://X.X.X.X 来访问它

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Jun 5, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In step, _simple_print_message_role now always logs self.run_context.messages, so the [BefCompact] and [AftCompact] logs will be identical; consider passing/using the provider-processed _provider_messages for the post-compaction log so the debug output actually reflects the transformation.
  • The tool call filtering in step builds valid_indices from zip(llm_resp.tools_call_name, llm_resp.tools_call_ids) but then indexes into llm_resp.tools_call_args using those indices; if tools_call_args is shorter than tools_call_name/tools_call_ids, this will raise IndexError, so it would be safer to derive indices from zipping all three lists or clamp to the minimum length.
  • The new _should_fix_modalities_for_provider only treats a non-empty list as a configured modalities value, whereas previously any truthy value (including non-lists) triggered sanitization; if there are providers with non-list modalities configs, this silently changes behavior, so consider either validating/normalizing modalities to a list or preserving the old truthiness semantics.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `step`, `_simple_print_message_role` now always logs `self.run_context.messages`, so the `[BefCompact]` and `[AftCompact]` logs will be identical; consider passing/using the provider-processed `_provider_messages` for the post-compaction log so the debug output actually reflects the transformation.
- The tool call filtering in `step` builds `valid_indices` from `zip(llm_resp.tools_call_name, llm_resp.tools_call_ids)` but then indexes into `llm_resp.tools_call_args` using those indices; if `tools_call_args` is shorter than `tools_call_name`/`tools_call_ids`, this will raise `IndexError`, so it would be safer to derive indices from zipping all three lists or clamp to the minimum length.
- The new `_should_fix_modalities_for_provider` only treats a non-empty `list` as a configured modalities value, whereas previously any truthy value (including non-lists) triggered sanitization; if there are providers with non-list `modalities` configs, this silently changes behavior, so consider either validating/normalizing `modalities` to a list or preserving the old truthiness semantics.

## Individual Comments

### Comment 1
<location path="astrbot/core/agent/runners/tool_loop_agent_runner.py" line_range="596-598" />
<code_context>
         log_context_sanitize_stats(stats)
         return sanitized_contexts

+    def _should_fix_modalities_for_provider(self) -> bool:
+        modalities = self.provider.provider_config.get("modalities", None)
+        return (
+            isinstance(modalities, list) and modalities
+        )  # Empty list is treated as unconfigured
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The new modalities check only supports non-empty `list` values and will skip sanitization for other sequence types.

This narrows the definition of “configured” from any truthy value to only a non-empty `list`. If a provider config uses another sequence type (e.g. a tuple), sanitization will now silently stop applying. If that’s intended, consider normalizing `modalities` to a list earlier; otherwise, widen the check to accept other iterable sequence types (or coerce to `list`) so the previous behavior is preserved while still treating `None`/`[]` as unconfigured.

Suggested implementation:

```python
    def _should_fix_modalities_for_provider(self) -> bool:
        modalities = self.provider.provider_config.get("modalities", None)

        # Treat None and empty sequences (e.g. [], (), etc.) as "unconfigured".
        # For non-sequence types, preserve the previous "truthy means configured" behavior.
        if modalities is None:
            return False

        try:
            from collections.abc import Sequence  # local import to avoid module-level changes if not already present
        except ImportError:  # very defensive; Sequence should be available in supported Python versions
            return bool(modalities)

        if isinstance(modalities, Sequence) and not isinstance(modalities, (str, bytes)):
            return len(modalities) > 0

        return bool(modalities)

```

If `Sequence` is already imported at the module level (e.g. `from collections.abc import Sequence`), you should remove the local import inside `_should_fix_modalities_for_provider` and rely on the existing import instead to keep imports centralized and avoid redundant imports.
</issue_to_address>

### Comment 2
<location path="astrbot/core/agent/runners/tool_loop_agent_runner.py" line_range="905-914" />
<code_context>
                 parts = None
+
+            # 过滤掉无效的 tool calls,确保 assistant 消息不包含无 id/name 的条目
+            if llm_resp.tools_call_name and llm_resp.tools_call_ids:
+                valid_indices = [
+                    i for i, (name, tid) in enumerate(
+                        zip(llm_resp.tools_call_name, llm_resp.tools_call_ids)
+                    )
+                    if name and tid
+                ]
+                if len(valid_indices) < len(llm_resp.tools_call_name):
+                    llm_resp.tools_call_name = [llm_resp.tools_call_name[i] for i in valid_indices]
+                    llm_resp.tools_call_args = [llm_resp.tools_call_args[i] for i in valid_indices]
+                    llm_resp.tools_call_ids = [llm_resp.tools_call_ids[i] for i in valid_indices]
+
+            # 如果过滤后没有有效的 tool calls,跳过构建 tool_calls_result
</code_context>
<issue_to_address>
**issue (bug_risk):** Filtering tool calls by index assumes `tools_call_args` is at least as long as `tools_call_name`/`tools_call_ids`, which may raise `IndexError` on malformed provider output.

`valid_indices` comes from `zip(tools_call_name, tools_call_ids)`, but is then applied to `tools_call_args` without verifying that `tools_call_args` is at least as long. If a provider returns fewer args than names/ids, indexing `tools_call_args[i]` will raise `IndexError`. To avoid this, build the filtered lists in a single pass over `zip(tools_call_name, tools_call_args, tools_call_ids)` and append only fully valid triples, or use `zip_longest` with explicit handling of missing values.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py
Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the tool loop agent runner to prevent mutating canonical messages during compaction, updates the LLM compressor parameters, and adds filtering to skip invalid tool calls with missing names or IDs. The review feedback highlights several critical issues: a parameter renaming mismatch that will cause an AttributeError in ContextManager, potential IndexError exceptions when accessing tool call names and arguments without bounds checks, and a type annotation mismatch where a method returns a list instead of a boolean.

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.

Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py
Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py
Comment thread astrbot/core/provider/entities.py
Comment thread astrbot/core/provider/entities.py Outdated
Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 5, 2026
@bytecategory
Copy link
Copy Markdown
Author

bytecategory commented Jun 5, 2026

Screenshot 2026-06-05 at 18-18-19 AstrBot - 仪表盘 效果如上 测一下 这次变更较为重要

@bytecategory bytecategory changed the title Fixed #8546 跨shi代的shi诗级的伟大的更新 Jun 5, 2026
@advent259141
Copy link
Copy Markdown
Member

首先,提交pr符合社区规范按照模板,不要起这种不知所云的标题。其次请原子化提交而不是把所有功能的修复和改动放到一个pr里。还有,配置证书和ssl这种事放在bot本体里会使得功能冗余,不适合作为一个feature放进来,这种事应该让nginx或者caddy来干。还有就是有很多无意义的改动。我将关闭这个pr,如果你愿意重新提交,请遵循社区规范使用模板,谢谢。

@bytecategory
Copy link
Copy Markdown
Author

bytecategory commented Jun 6, 2026

首先,提交pr符合社区规范按照模板,不要起这种不知所云的标题。其次请原子化提交而不是把所有功能的修复和改动放到一个pr里。还有,配置证书和ssl这种事放在bot本体里会使得功能冗余,不适合作为一个feature放进来,这种事应该让nginx或者caddy来干。还有就是有很多无意义的改动。我将关闭这个pr,如果你愿意重新提交,请遵循社区规范使用模板,谢谢。

首先 你只会看标题 不会看git commit -m "这里的字面量"
其次 配置证书和ssl是必须的 此后还得做好http跳转https 没有配置就只能通过ssh转发来访问.在我遵循社区规范使用模板之前 你能不能把https://github.com/advent259141/advent259141 改一下 以免让人发现你连Markdown都不会就来指手画脚
还有你说我做了很多无意义的改动 那是因为你根本不懂开发 按照 #8552 (comment) 的说法 你还是滚回墙内好了.
真正无意义的改动 都在#8590 (review) 这里了 这种边界检查没有必要 这种情况除非你把自己封装成了llm api供大家调用才会出现 当然有没有人用是另一回事.
@Soulter

@advent259141
Copy link
Copy Markdown
Member

首先,提交pr符合社区规范按照模板,不要起这种不知所云的标题。其次请原子化提交而不是把所有功能的修复和改动放到一个pr里。还有,配置证书和ssl这种事放在bot本体里会使得功能冗余,不适合作为一个feature放进来,这种事应该让nginx或者caddy来干。还有就是有很多无意义的改动。我将关闭这个pr,如果你愿意重新提交,请遵循社区规范使用模板,谢谢。

首先 你只会看标题 不会看git commit -m "这里的字面量" 其次 配置证书和ssl是必须的 此后还得做好http跳转https 没有配置就只能通过ssh转发来访问.在我遵循社区规范使用模板之前 你能不能把https://github.com/advent259141/advent259141 改一下 以免让人发现你连Markdown都不会就来指手画脚 还有你说我做了很多无意义的改动 那是因为你根本不懂开发 按照 #8552 (comment) 的说法 你还是滚回墙内好了. 真正无意义的改动 都在#8590 (review) 这里了 这种边界检查没有必要 这种情况除非你把自己封装成了llm api供大家调用才会出现 当然有没有人用是另一回事. @Soulter

很明显我好好说的的建议你一个也没听进去,那我们也没讨论的必要了

@bytecategory
Copy link
Copy Markdown
Author

继续保持健康模式为true吧,真健康...

@bytecategory
Copy link
Copy Markdown
Author

bytecategory commented Jun 6, 2026

很明显我好好说的的建议你一个也没听进去,那我们也没讨论的必要了

很明显我每个都听了 听不进去你想想自己的问题 现在标题改了

@bytecategory bytecategory changed the title 跨shi代的shi诗级的伟大的更新 Fixed #8546 and also fixed #8552 Jun 6, 2026
@exynos967
Copy link
Copy Markdown
Contributor

exynos967 commented Jun 6, 2026

很明显我好好说的的建议你一个也没听进去,那我们也没讨论的必要了

很明显我每个都听了 听不进去你想想自己的问题

对贡献者一点基本的尊重和礼貌都没有,你的礼仪去哪了呢???你有没有去了解过设计出健康模式的意图在哪里?适配器平台的位置改动是何意味?pr2个无意义的功能改动,这不是你的项目ok?别在开源社区里乱叫。
f00a54b6a1e5725811d226f55787ef06

@lxfight
Copy link
Copy Markdown
Member

lxfight commented Jun 6, 2026

首先,提交pr符合社区规范按照模板,不要起这种不知所云的标题。其次请原子化提交而不是把所有功能的修复和改动放到一个pr里。还有,配置证书和ssl这种事放在bot本体里会使得功能冗余,不适合作为一个feature放进来,这种事应该让nginx或者caddy来干。还有就是有很多无意义的改动。我将关闭这个pr,如果你愿意重新提交,请遵循社区规范使用模板,谢谢。

首先 你只会看标题 不会看git commit -m "这里的字面量" 其次 配置证书和ssl是必须的 此后还得做好http跳转https 没有配置就只能通过ssh转发来访问.在我遵循社区规范使用模板之前 你能不能把https://github.com/advent259141/advent259141 改一下 以免让人发现你连Markdown都不会就来指手画脚 还有你说我做了很多无意义的改动 那是因为你根本不懂开发 按照 #8552 (comment) 的说法 你还是滚回墙内好了. 真正无意义的改动 都在#8590 (review) 这里了 这种边界检查没有必要 这种情况除非你把自己封装成了llm api供大家调用才会出现 当然有没有人用是另一回事. @Soulter

你自己一点教养没有,社区要求不遵守,连最基本的标题都不会写,每一句话都透露着你骨子里的那股自负的酸臭味

@bytecategory
Copy link
Copy Markdown
Author

首先,提交pr符合社区规范按照模板,不要起这种不知所云的标题。其次请原子化提交而不是把所有功能的修复和改动放到一个pr里。还有,配置证书和ssl这种事放在bot本体里会使得功能冗余,不适合作为一个feature放进来,这种事应该让nginx或者caddy来干。还有就是有很多无意义的改动。我将关闭这个pr,如果你愿意重新提交,请遵循社区规范使用模板,谢谢。

首先 你只会看标题 不会看git commit -m "这里的字面量" 其次 配置证书和ssl是必须的 此后还得做好http跳转https 没有配置就只能通过ssh转发来访问.在我遵循社区规范使用模板之前 你能不能把https://github.com/advent259141/advent259141 改一下 以免让人发现你连Markdown都不会就来指手画脚 还有你说我做了很多无意义的改动 那是因为你根本不懂开发 按照 #8552 (comment) 的说法 你还是滚回墙内好了. 真正无意义的改动 都在#8590 (review) 这里了 这种边界检查没有必要 这种情况除非你把自己封装成了llm api供大家调用才会出现 当然有没有人用是另一回事. @Soulter

你自己一点教养没有,社区要求不遵守,连最基本的标题都不会写,每一句话都透露着你骨子里的那股自负的酸臭味

竟然还有自我介绍

@bytecategory
Copy link
Copy Markdown
Author

bytecategory commented Jun 6, 2026

很明显我好好说的的建议你一个也没听进去,那我们也没讨论的必要了

很明显我每个都听了 听不进去你想想自己的问题

别在开源社区里乱吠。

我永远不会和一个纯傻逼对骂 因为它会把我的智商拉到和它一个等级 然后用它当了多年傻逼的丰富经验击败我
还有你们这氛围配开源社区四个字吗?

@Maple127667
Copy link
Copy Markdown

招不招笑?连最基本的开源项目的贡献流程都不清楚,还人身攻击其他贡献者,你也是无敌了 <img alt=“” width=“320”

说的好像你很清楚一样 人身攻击其他贡献者 那我还忘攻击你了是不是,你也是太幸运了

“骂人”和“人身攻击”什么时候成了开源贡献者的标配了?真正成熟的贡献者关注的是代码逻辑、技术方案和社区发展,而不是在这里用“忘攻击你了”这种小儿科的话来搞人身威胁。
技术交流欢迎讨论,但如果是缺乏底线的口水战,恕不奉陪。请你把精力放在提交有价值的 Code 上,而不是在评论区展示你的戾气和低能。

那你根据我的改动 解释一下llm_compress_keep_recent_ratio这个配置有没有失效 在哪一条断了 还有 我看到的是你们的戾气与低能 再也不见 互不骚扰了!

你对别人的攻击真的是很精辟的符合了你自身的形象

@xunxiing
Copy link
Copy Markdown
Contributor

xunxiing commented Jun 6, 2026

招不招笑?连最基本的开源项目的贡献流程都不清楚,还人身攻击其他贡献者,你也是无敌了 <img alt="" width="320"

说的好像你很清楚一样 人身攻击其他贡献者 那我还忘攻击你了是不是,你也是太幸运了

“骂人”和“人身攻击”什么时候成了开源贡献者的标配了?真正成熟的贡献者关注的是代码逻辑、技术方案和社区发展,而不是在这里用“忘攻击你了”这种小儿科的话来搞人身威胁。

技术交流欢迎讨论,但如果是缺乏底线的口水战,恕不奉陪。请你把精力放在提交有价值的 Code 上,而不是在评论区展示你的戾气和低能。

那你根据我的改动 解释一下llm_compress_keep_recent_ratio这个配置有没有失效 在哪一条断了

还有 我看到的是你们的戾气与低能 再也不见 互不骚扰了!

一路走好哦,最好再也别回来了

@lingyun14beta
Copy link
Copy Markdown
Contributor

AstrBot 是多平台项目,而你的自动申请证书在原生 Windows 几乎不可用

@preca-hoshino
Copy link
Copy Markdown

前3个修改可以。自动申请Lets encrypt的免费证书可以交给另外项目来完成,Astrbot不适合支持。后面的“Telegram适配器位置改到最前面”“最大步数改成114514”是合意味?如果你是想豪到我那你赢了
Image_1780726780519_407

@Sisyphbaous-DT-Project
Copy link
Copy Markdown
Contributor

感觉大家都在骂他的为人,骂他的语气, 骂他没有按照规范写描述,但就是没有人仔细看看他的pr和issue,其实你要是仔细看看的话,你就会发现...你其实骂轻了

@wfqefwqf
Copy link
Copy Markdown

wfqefwqf commented Jun 6, 2026

轻松绷住

@jjghfd
Copy link
Copy Markdown

jjghfd commented Jun 6, 2026

合影留念(这期神完了,豪死我了)

@vmoranv
Copy link
Copy Markdown
Contributor

vmoranv commented Jun 6, 2026

db87beb633b17a5a8e7821d28e7a18a9

@CreeperIsASpy
Copy link
Copy Markdown

大多更改其实只是你不理解规范导致的。
“不理解”,提问就可以。
但是,“不尊重”就只能挨骂咯。

@Him666233
Copy link
Copy Markdown

慕名而来,你也真是无敌了。其他的不说你什么,但是那个改成114514和把Telegram挪到最前面是何意味,有点像是你想意淫想改所以就改出来的东西,压根就没有实际意义。也压根根本没有考虑到广大astrBot大部分人的用户使用场景,还搁这儿说别人呢,你就别在这里发癫了,提交pr申请的时候做不到最基础的礼貌这个尊重,哪怕你提交这些东西是有进步的,是对的, 也不会有人尊重你的,因为是你提前不尊重别人,更何况你交的还是这一坨。

@Weirenshanxia
Copy link
Copy Markdown

你已急哭

@zhang19hao
Copy link
Copy Markdown

项目里放木马的来了

@Kamishirasawa-keine
Copy link
Copy Markdown

我承认我是被引流来的
到此一游

@Waterwzy
Copy link
Copy Markdown
Contributor

Waterwzy commented Jun 6, 2026

慕名而来,震撼首发,合影喵!

其实其他人都说的很详细了,我着重说一下最令人昏厥的一点:

什么叫最大循环轮数为114514?对于正常的用户请求,我敢说没有任何一种情况可以到达这个轮数,那这个上限就是毫无意义的。

30虽然客观上说没有一个比较合理的依据,但是很容易让人理解这样做的目的:限制某些情况下agent调用轮次防止过多的上下文消耗,我知道114514是什么但是很可惜开源项目的源代码不是你玩梗的敌方。

@yuegujun-puk
Copy link
Copy Markdown

慕名而来,真被吓哭了,我从来没见过如此逆天的,我的评价是——人类毁灭吧,地球完蛋吧,外星人快来占领吧
求你搞点人干得出来的事吧

@jinyiwei2012
Copy link
Copy Markdown

慕名而来 豪到我了

@rong-xiaoli
Copy link
Copy Markdown

见证互联网多样性

@Yangyuwuhan
Copy link
Copy Markdown

慕名而来,114514 是何意味啊?

@LIghtJUNction
Copy link
Copy Markdown
Member

请你撤回这个提交
bytecategory@19e4650

@SSChen09
Copy link
Copy Markdown

SSChen09 commented Jun 6, 2026

合影留恋

@Quirrel-zh
Copy link
Copy Markdown
Contributor

大家好,出来遛狗来了

@Enterausermame
Copy link
Copy Markdown

还有高手,嘉豪翻墙翻出优越感了

@C0j23T
Copy link
Copy Markdown

C0j23T commented Jun 6, 2026

请你撤回这个提交 bytecategory@19e4650

我超,盒😨

@LinQingYuu
Copy link
Copy Markdown

LinQingYuu commented Jun 6, 2026

这事已经传遍我的小群了(逃


请你撤回这个提交 bytecategory@19e4650

可以考虑 DMCA 喵

@pwupink
Copy link
Copy Markdown

pwupink commented Jun 6, 2026

合影合影

@Blueteemo
Copy link
Copy Markdown
Contributor

慕名而来,合影留念~这期神完了🤣

@Last-emo-boy
Copy link
Copy Markdown

慕名而来
合影留念

@ChinoKou
Copy link
Copy Markdown

ChinoKou commented Jun 6, 2026

36CEB328B09EA6E77C9977EA292CC61E

@superphosphate
Copy link
Copy Markdown

恭迎编程圈皇帝莅临astrbot!

@AstrBotDevs AstrBotDevs locked as too heated and limited conversation to collaborators Jun 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area:core The bug / feature is about astrbot's core, backend area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

当llm调用工具时把function.name设置成None会崩溃 删除个目录 被阻止了