Repository navigation
fix(agent): finish runner reset when skills_like mode has no tools - #10707
Open
rudycelekli wants to merge 2 commits into
Open
rudycelekli wants to merge 2 commits into
rudycelekli wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_tool_loop_agent_runner.py" line_range="696" />
<code_context>
+ pass
+
+ assert runner.done()
+ assert runner.stats.end_time >= runner.stats.start_time
+
+
</code_context>
<issue_to_address>
**Clock rollback flakes completion check**
When the system clock moves backwards between `reset()` and completion, the test compares `end_time` with `start_time` at line 696, so a backward system-clock adjustment between `reset()` and completion makes this assertion fail even when the run completes correctly.
Use a controlled clock in the test or avoid relying on wall-clock ordering for this assertion.
</issue_to_address>
### Comment 2
<location path="tests/test_tool_loop_agent_runner.py" line_range="689" />
<code_context>
+ tool_schema_mode="skills_like",
+ )
+
+ assert [m.role for m in runner.run_context.messages] == ["system", "user"]
+ assert runner.stats.start_time > 0
+
</code_context>
<issue_to_address>
**Prompt contents can be dropped unnoticed**
When the system and user messages are present but their contents are empty, the test checks only role names at line 689, so empty `system` and `user` contents still satisfy the assertion; `MockProvider.text_chat()` does not inspect the messages and returns a final reply, letting the run pass without sending either prompt.
Assert the expected message contents, or verify that the provider receives them.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: tests/test_tool_loop_agent_runner.py:696, tests/test_tool_loop_agent_runner.py:689
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10698
ToolLoopAgentRunner.reset()returns early whentool_schema_mode == "skills_like"and the request has no tools (req.func_toolisNone/empty). That earlyreturnskips everything after the skills_like block:self.run_context.messagesis never built, so the system prompt, history and current user message are not sent;self.statsis never created, so the firststep()crashes withAttributeError: 'ToolLoopAgentRunner' object has no attribute 'stats'.self.statsis only assigned at the very end ofreset(), andreset()is always awaited before stepping, so this early return is the only way to reachstep()without stats. It is hit by any request that ends up with no tools in skills_like mode (for example active replies or sessions where all tools are disabled). Older configs that were migrated still carrytool_schema_mode: "skills_like".Modifications / 改动点
astrbot/core/agent/runners/tool_loop_agent_runner.py: only apply the light/param-only tool schema split when tools are present, instead of returning fromreset(). Behavior with tools is unchanged.tests/test_tool_loop_agent_runner.py: regression test for skills_like mode withfunc_tool=None.This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Without the fix the new test fails (
assert [] == ['system', 'user']); with the fix:ruff format/ruff checkpass.Checklist / 检查清单
Summary by Sourcery
Complete runner reset initialization for skills_like requests that have no tools.
Bug Fixes:
Tests:
Review follow-up (2026-10-26)
Updated both assertions: the runner module now receives a controlled clock (1000 at reset, 1005 at completion), and the test checks exact system/user contents (
sys,hello) as well as their roles. The clock stub is local to the runner module rather than replacing the global time module. Fulltests/test_tool_loop_agent_runner.py: 61 passed. Whole-repository Ruff lint and format checks pass. Tested under isolated Python 3.13.5 with existing dependencies; hosted Python 3.12 CI remains separate. No live provider calls.