Skip to content

Editing history in realtime #2219

@Shadetail

Description

@Shadetail

Issue

As the session grows longer, history that is actually being sent to the model with each inference becomes more and more compressed. Often I have situations where I go in circles for a while with the model trying to fix some detail and after finally succeeding, I'm left wondering how much the model "remembers" at this point about what our original goal was and where we are. And I'm also in the position where I know that a large chunk of that history is currently being wasted on something that will be irrelevant going forward.

One of the things I can do in this situation is to /clear the history and summarize what we are doing and where we are at with our implementation and what we should do next, effectively replacing the history with my own summarized version of it being sent as a prompt, which then automatically becomes history from then on.

But I feel like this micromanagement is wasting a lot of my time, and Aider is all about automating away such things.

So would it be possible somehow to be able to see the current history, to see it exactly as it will be sent to the model with the next reply, and to be able to edit it before it gets sent.

I know that there is .aider.chat.history.md, and that it's in principle editable. But this file isn't actually being used for this purpose, it's grows far too large for it far too quickly, and it also contains a bunch of unrelated system stuff like "> Tokens: 38k sent, 1.1k received." which are all irrelevant to the model and would only hinder its performance. Interestingly, the .aider.chat.history.md is used in one case, only when using the --restore-chat-history command, which I'm not a fan off for those same reasons. Often this file will grow to an incredible size, and then the --restore-chat-history command will cause that entire file to be sent to the model, presumably to summarize it. I kind of stopped using that command entirely, and just write the summary myself, as my .aider.chat.history.md for the project I'm working on right now is about to hit the size of 1 million tokens. (edit: looking at the Aider code, it looks like the entire history file is not actually being sent, even though /tokens implied that it is)

This makes it difficult for me to close Aider, as once I close it I know that my history will be lost and I'll have to re-summarize it myself to the model. Having the ability to export and import the actual realtime history state would solve this problem as well.

I also know about .aider.llm.history, from which the history that I'm talking about could be extracted from, in principle, but for me this file is 45MB and is very time consuming to parse and find what I'm looking for, and when I do, the history I see there often looks very strange. Here's what it currently looks like for me:
History extract from aider.llm.history.txt
90% of it, everything from the line 20 onwards seems to be a hallucinated waste of tokens.

But even if I do go through the trouble of extracting it like this, and even if it's in good condition somehow, I'd still have to delete the USER prefixes, /clear the history and insert this into my prompt.

It would be ideal to have the current state of this realtime history saved to a file, much like .aider.chat.history.md is, and then have the content of the file read each time the history is being sent. This way I could also more easily keep this history in good condition myself by fixing hallucations, removing irrelevant bits, and reintroducing important stuff that may have been dropped.

Version and model info

Aider v0.60.1
Main model: claude-3-5-sonnet-20241022 with diff edit format, prompt cache, infinite output
Weak model: claude-3-haiku-20240307

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions