Skip to content

Fix missing tail tokens in ChatSummary.summarize_real #3722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions aider/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,22 @@ def summarize_real(self, messages, depth=0):
if split_index <= min_split:
return self.summarize_all(messages)

head = messages[:split_index]
tail = messages[split_index:]

sized = sized[:split_index]
head.reverse()
sized.reverse()

sized_head = sized[:split_index]
sized_head.reverse()
keep = []
total = 0

# These sometimes come set with value = None
model_max_input_tokens = self.models[0].info.get("max_input_tokens") or 4096
model_max_input_tokens -= 512

for i in range(split_index):
total += sized[i][0]
for tokens, msg in sized_head:
total += tokens
if total > model_max_input_tokens:
break
keep.append(head[i])
keep.append(msg)

keep.reverse()

Expand Down