Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Two moderate issues remain in empty-response parsing.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
This PR treats normally completed empty OpenAI responses as successful without retries, fallback, or empty assistant history entries.
Changes:
- Accept empty
stopcompletions without raw tool calls. - Preserve metadata, hooks, and tool history.
- Add streaming and agent regression coverage.
| File | Summary |
|---|---|
tests/test_tool_loop_agent_runner.py |
Tests completion, retry, fallback, hooks, and history behavior. |
tests/test_openai_source.py |
Tests empty and streamed OpenAI response handling. |
astrbot/core/provider/sources/openai_source.py |
Handles successful empty completions. Two moderate findings remain: legacy function_call handling and empty reasoning normalization. |
astrbot/core/agent/runners/tool_loop_agent_runner.py |
Finalizes empty turns without invalid assistant history entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Contributor
Author
|
@sourcery-ai review |
Contributor
Author
|
@sourcery-ai review |
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.

Problem
Models can finish successfully without another visible reply, for example after a message-sending tool has delivered the result. AstrBot rejects these empty turns, retries completed work and may unnecessarily switch providers. This affects both Chat Completions (
finish_reason="stop") and Responses (status="completed"). Empty assistant history can also produce invalid Gemini text parts.Related: #7409, #7044. This revisits closed, unmerged #7410; #7104 introduced dedicated empty-output retries.
Changes
stopwithout raw tool calls, legacy function calls or refusals.completedwithout errors, incomplete details, unhandled output or unfinished output items. Preserve response ID, raw completion, token usage and encrypted reasoning state. Unparsed tool calls, empty refusals and unsupported output remain errors.None. Complete the agent without appending an empty assistant text message; retain existing tool history.The Responses parser is shared by non-streaming and terminal streaming events. Streams without a terminal event still fail. This PR does not make thought signatures portable between different providers.
Validation
pytest -q tests/test_openai_responses_source.py tests/test_openai_source.py tests/test_tool_loop_agent_runner.py tests/test_gemini_source.py— 207 passed.git diff --checkpassed.Tests use mocked responses; no live model requests or group messages were sent.