fix(agent): deliver skills-like fallback replies when streaming - #10025
Merged
Soulter merged 2 commits intoSep 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is tightly scoped, aligns with the stated streaming bridge semantics, and is covered by targeted regression tests that exercise the real runner/bridge behavior.
Pull request overview
This PR fixes a streaming delivery gap in the skills_like tool-schema re-query fallback path: when the re-query returns a plain assistant reply (no tool calls), the final answer previously only emitted llm_result and could be persisted to history without being delivered to streaming consumers.
Changes:
- Emit the
skills_likeno-tool re-query fallback reply asstreaming_delta(when streaming is enabled) while still emittingllm_resultfor non-streaming / stream-to-general consumers. - Ensure
_complete_with_assistant_response()(and thus agent-done hooks) runs before emitting the fallback content. - Add regression tests covering streaming vs non-streaming, reasoning visibility, stream-to-general behavior, exactly-once delivery, and “normal streaming reply not duplicated” controls.
File summaries
| File | Description |
|---|---|
astrbot/core/agent/runners/tool_loop_agent_runner.py |
Moves fallback completion before emission and emits fallback content via streaming_delta in streaming mode (plus llm_result for non-streaming consumers). |
tests/test_tool_loop_agent_runner.py |
Adds/extends tests to validate fallback delivery and hook ordering across streaming modes and to ensure ordinary streaming replies are not duplicated. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Soulter
approved these changes
Sep 10, 2026
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 #10024
Motivation
With
skills_likeand streaming enabled, a tool-schema re-query can return a plain assistant reply instead of another tool call. The re-query uses non-streamingtext_chat(), but this fallback only emitsllm_result. The streaming bridge consumesstreaming_delta, so the final reply is saved to history without reaching the user.Modifications
streaming_deltawhen streaming is enabled, while retainingllm_resultfor non-streaming and stream-to-general consumers._complete_with_assistant_response()call, so they use the post-hook reply. Do not move the existingllm_resultemissions or hook invocation.llm_resultthere would duplicate ordinary streamed replies.No new settings, dependencies, platform-specific changes, or changes to cron notification policy.
Scope: only the missing streaming events in #10024. The existing non-streaming/stream-to-general
llm_result-before-hook behavior is preserved. The separate hook-ordering issue #9788 is left to #9789 / #9835; this PR no longer changes that ordering. The production diff only adds 20 lines in the fallback branch.Verification Steps and Test Results
Based on upstream
masterat6fb50cae9.Added regressions exercise the real
ToolLoopAgentRunner, its schema re-query, andrun_agent()with a deterministic fake provider/event. Coverage includes:completion_textandresult_chainfallback replies.Before the fix, the new regression matrix fails (including missing final replies on the streaming cases); the ordinary streaming control passes. After the fix:
The warning is the existing Python
audioopdeprecation warning.Tests are local and deterministic; no real provider calls or platform messages were sent, and the production deployment was not modified. This is not a live Feishu end-to-end test.
Checklist
Summary by Sourcery
Ensure assistant replies produced by skills-like tool-schema re-queries reach streaming consumers without duplication.
Bug Fixes:
Enhancements:
Tests: