Skip to content

Commit

Permalink
refactor: Handle KeyboardInterrupt with user-assistant message pair a…
Browse files Browse the repository at this point in the history
…nd add env check for sanity_check_messages
  • Loading branch information
paul-gauthier committed Jan 22, 2025
1 parent 843720a commit 42ef435
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,10 @@ def send_message(self, inp):
interrupted = True

if interrupted:
content += "\n^C KeyboardInterrupt"
self.cur_messages += [dict(role="assistant", content=content)]
self.cur_messages += [
dict(role="user", content="^C KeyboardInterrupt"),
dict(role="assistant", content="I see that you interrupted my previous reply."),
]
return

edited = self.apply_updates()
Expand Down
4 changes: 3 additions & 1 deletion aider/sendchat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
import json
import os
import time

from aider.dump import dump # noqa: F401
Expand Down Expand Up @@ -51,7 +52,8 @@ def send_completion(
):
#
#
# sanity_check_messages(messages)
if os.environ.get("AIDER_SANITY_CHECK_TURNS"):
sanity_check_messages(messages)
#
#

Expand Down

0 comments on commit 42ef435

Please sign in to comment.