From 13d24278f287f7313c8ceddf4622d5f778d91611 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 22 Jan 2025 09:30:05 -0800 Subject: [PATCH] feat: Add assistant reply for token limit exhaustion in base_coder --- aider/coders/base_coder.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 7f5f613c9..52754309e 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1326,13 +1326,21 @@ class Coder: self.show_usage_report() + self.add_assistant_reply_to_cur_messages() + if exhausted: + if not self.cur_messages or self.cur_messages[-1]["role"] == "user": + self.cur_messages += [ + dict( + role="assistant", + content="FinishReasonLength exception: you sent too many tokens", + ), + ] + self.show_exhausted_error() self.num_exhausted_context_windows += 1 return - self.add_assistant_reply_to_cur_messages() - if self.partial_response_function_call: args = self.parse_partial_args() if args: