-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: skills_like 模式下保留原始 completion_text,修复上下文分裂问题 #8240
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
Open
EmilyCheoh
wants to merge
2
commits into
AstrBotDevs:master
Choose a base branch
from
EmilyCheoh:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -816,8 +816,9 @@ async def step(self): | |
| # 如果有工具调用,还需处理工具调用 | ||
| if llm_resp.tools_call_name: | ||
| if self.tool_schema_mode == "skills_like": | ||
| llm_resp, _ = await self._resolve_tool_exec(llm_resp) | ||
| if not llm_resp.tools_call_name: | ||
| requery_resp, _ = await self._resolve_tool_exec(llm_resp) | ||
| if not requery_resp.tools_call_name: | ||
| llm_resp = requery_resp | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| logger.warning( | ||
| "skills_like tool re-query returned no tool calls; fallback to assistant response." | ||
| ) | ||
|
|
@@ -845,6 +846,10 @@ async def step(self): | |
|
|
||
| await self._complete_with_assistant_response(llm_resp) | ||
| return | ||
| else: | ||
| llm_resp.tools_call_name = requery_resp.tools_call_name | ||
| llm_resp.tools_call_args = requery_resp.tools_call_args | ||
| llm_resp.tools_call_ids = requery_resp.tools_call_ids | ||
|
|
||
| tool_call_result_blocks = [] | ||
| cached_images = [] # Collect cached images for LLM visibility | ||
|
|
||
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.
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.
在
skills_like模式下,重新查询(re-query)产生的 token 消耗目前没有被计入self.stats.token_usage。这会导致代理运行的 token 统计不准确。建议在获取requery_resp后,如果它是一个新的响应对象,则累加其 usage,并同步更新会话的 token 使用量。