Skip to content

Exceptions in the output task result in an empty response with no explanation #184

@pjcreath

Description

@pjcreath

Issue

The exception, of course, was my fault, but the symptoms were mystifying: all subsequent prompts would do nothing until I restarted aider. Troubleshooting was not fun.

Here's a sample fix:

diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py
index f9564a61b..2c7b1d89f 100755
--- a/aider/coders/base_coder.py
+++ b/aider/coders/base_coder.py
@@ -1323,10 +1323,18 @@ class Coder:
                             if isinstance(exception, SwitchCoder):
                                 await self.io.output_task
                                 raise exception
+                            self.io.tool_error(f"Error during generation: {exception}")
+                            if self.verbose:
+                                traceback.print_exception(
+                                    type(exception), exception, exception.__traceback__
+                                )
 
                         # Stop spinner when processing task completes
                         self.io.stop_spinner()
 
+                        # and stop monitoring the output task
+                        self.io.output_task = None
+
                 await self.auto_save_session()
                 await asyncio.sleep(0.01)  # Small yield to prevent tight loop

Note that we have to clear self.io.output_task to avoid infinite output. Breaking the while loop prevented any output, and raising the exception caused a tight infinite loop elsewhere.

Version and model info

Aider v0.88.27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions