🪲 BUG-#69: Retry and surface clear error on empty response - #71
Merged
Conversation
FernandoCelmer
commented
Aug 16, 2026
Member
Author
There was a problem hiding this comment.
🔍 Code Review
Code issues found: 2
| # | Severity | Comment |
|---|---|---|
| 1 | [Blocking] | Usage silently lost on give-up path |
| 2 | [Suggestion] | Session left inconsistent on early return |
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.
Description
pycodeloop/core/agent.py: Added_MAX_EMPTY_RESPONSE_RETRIES = 2module-level constant and a retry loop insiderun()that detects empty responses (no text, no tool calls) and retries up to 2 times before returning a descriptive error string naming the model.tests/core/test_agent.py: Added two regression tests — one verifying recovery after transient empty responses, one verifying the give-up error message after exhausting retries.Motivation and Context
Weak models (e.g. Ollama
qwen2.5:3bin agent mode) can return a fully empty message with no text and no tool calls. The agent loop previously treated this as a normal "done" turn and silently returned"". This change retries up to 2 times and, if all attempts fail, surfaces a clear error message naming the model instead of silently succeeding with empty output.Closes #69
Types of changes
Checklist