Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion astrbot/core/agent/runners/tool_loop_agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,28 @@ async def step(self):
logger.warning(
"skills_like tool re-query returned no tool calls; fallback to assistant response."
)
if llm_resp.role == "err":
# The re-query returned a provider error instead of a normal
# assistant response; route it through error handling instead
# of finalizing it as assistant content.
self.final_llm_resp = llm_resp
self.stats.end_time = time.time()
self._transition_state(AgentState.ERROR)
self._resolve_unconsumed_follow_ups()
custom_error_message = self._get_persona_custom_error_message()
error_text = custom_error_message or (
f"LLM 响应错误: {llm_resp.completion_text or '未知错误'}"
)
yield AgentResponse(
type="err",
data=AgentResponseData(
chain=MessageChain().message(error_text),
),
)
return
# Finalize before yielding so response hooks can review or rewrite
# the fallback text before downstream stages send it.
await self._complete_with_assistant_response(llm_resp)
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
if llm_resp.reasoning_content:
yield AgentResponse(
type="llm_result",
Expand All @@ -958,7 +980,6 @@ async def step(self):
),
)

await self._complete_with_assistant_response(llm_resp)
return
else:
llm_resp.tools_call_name = requery_resp.tools_call_name
Expand Down
Loading