Skip to content

Chat History

Chat with claude-3-5-sonnet

I want to learn more about how this program decides how much chat history to provide when ada is invoked with minus minus restore minus chat minus history.

Repo-map can't include /home/m/Code/github.com/Aider-AI/aider/docker/Dockerfile Has it been deleted from the file system but not from git?

I'll help you analyze how the chat history handling works. Based on the file summaries, this functionality appears to be primarily handled in aider/history.py and aider/models.py.

To see the complete implementation details, I'll need to see the full contents of:

  1. aider/history.py - This contains the ChatSummary class which appears to handle chat history summarization
  2. aider/models.py - This contains the Model class which has max_chat_history_tokens and token_count() method

Could you please share the full contents of these files?

The key components I can see so far:

  1. Model class has a max_chat_history_tokens property set to 1024 by default
  2. ChatSummary class takes max_tokens parameter (also defaulting to 1024)
  3. Both classes have methods for token counting

But I'll need to see the actual implementation details to explain exactly how the chat history size is determined and managed. Could you share those files? Tokens: 3.6k sent, 217 received. Cost: $0.01 message, $0.01 session. Add aider/history.py to the chat? (Y)es/(N)o/(A)ll/(S)kip all/(D)on't ask again [Yes]:
Add aider/models.py to the chat? (Y)es/(N)o/(A)ll/(S)kip all/(D)on't ask again [Yes]:
From reviewing the files, I can explain how the chat history size is determined. The key components are in both files:

  1. In aider/models.py, the Model class sets max_chat_history_tokens based on the model's context window:

    max_input_tokens = self.info.get("max_input_tokens") or 0
    if max_input_tokens < 32 * 1024:
        self.max_chat_history_tokens = 1024
    else:
        self.max_chat_history_tokens = 2 * 1024
    

  2. In aider/history.py, the ChatSummary class handles summarizing chat history when it gets too large:

  3. It takes a max_tokens parameter (defaulting to 1024)
  4. Uses too_big() to check if messages exceed the token limit
  5. Has a summarize() method that recursively breaks down and summarizes chat history to fit within the token limit

The basic flow is: 1. Model's max chat history is set to either 1024 or 2048 tokens depending on context window 2. When restoring chat history, if it exceeds the limit: - Messages are split into chunks - Older messages are summarized recursively - Recent messages are kept verbatim - This continues until the entire history fits within the token limit

To see the complete flow of chat history restoration, we should also look at where ChatSummary is used. Could you share the file that handles the --restore-chat-history flag? Tokens: 13k sent, 316 received. Cost: $0.04 message, $0.06 session.