Skip to content

🪲 BUG-#69: Retry and surface clear error on empty response - #71

Merged
FernandoCelmer merged 4 commits into
masterfrom
feature/69
Aug 16, 2026
Merged

🪲 BUG-#69: Retry and surface clear error on empty response#71
FernandoCelmer merged 4 commits into
masterfrom
feature/69

Conversation

@FernandoCelmer

@FernandoCelmer FernandoCelmer commented Aug 16, 2026

Copy link
Copy Markdown
Member

Description

  • pycodeloop/core/agent.py: Added _MAX_EMPTY_RESPONSE_RETRIES = 2 module-level constant and a retry loop inside run() 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:3b in 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

  • Bug fix (change that fixes an issue)
  • New feature (change which adds functionality)
  • Documentation

Checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG
  • I have updated the documentation accordingly

@FernandoCelmer FernandoCelmer added the bug Something isn't working label Aug 16, 2026

@FernandoCelmer FernandoCelmer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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

Comment thread pycodeloop/core/agent.py
Comment thread pycodeloop/core/agent.py
@FernandoCelmer
FernandoCelmer merged commit 3db8a13 into master Aug 16, 2026
8 checks passed
@FernandoCelmer
FernandoCelmer deleted the feature/69 branch August 16, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty assistant response with no tool calls under Ollama agent mode (qwen2.5:3b)

1 participant