From 22fc961dc0f87b22d146c831683a157914481faa Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 5 Dec 2024 18:57:24 -0800 Subject: [PATCH] fix: add empty list check before accessing last chat chunk --- aider/coders/editor_editblock_coder.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/aider/coders/editor_editblock_coder.py b/aider/coders/editor_editblock_coder.py index 04b670715..1dd975e94 100644 --- a/aider/coders/editor_editblock_coder.py +++ b/aider/coders/editor_editblock_coder.py @@ -29,3 +29,20 @@ class EditorEditBlockCoder(EditBlockCoder): markdown += content + "\n\n" return markdown.strip() + + def format_chat_chunks(self): + chunks = super().format_chat_chunks() + # Only add reminder if there are current messages + if chunks.cur: + final = chunks.cur[-1] + if self.main_model.reminder == "sys": + chunks.reminder = self.reminder_message + elif self.main_model.reminder == "user" and final["role"] == "user": + # stuff it into the user message + new_content = ( + final["content"] + + "\n\n" + + self.fmt_system_prompt(self.gpt_prompts.system_reminder) + ) + chunks.cur[-1] = dict(role=final["role"], content=new_content) + return chunks