-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Refactor to a helper class for the agent's history (ConversationMemory) #7008
Conversation
events = condensed_history | ||
|
||
logger.debug( | ||
f'Processing {len(events)} events from a total of {len(state.history)} events' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the only place where the state
is used. Do we expect more need for state access in this function or can we simplify the arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did wonder that, and I think we may want State
here, but my thoughts are not fully baked, because it also depends if we will want to keep condensers separate or trigger them from here:
- maybe
truncation_id
(for the truncation that is now in the controller, is saved instate
) - maybe
start_id
/end_id
if we will manage delegates histories here (the "inner" delegate agent shares the same stream with the parent, but its history starts with astart_id
, not with event 0)
Idk, there are plenty other things saved in state, and since this class is an agent helper explicitly, it has the "right" to them, so to speak. But it's entirely reasonable to remove it now, and bring it back when we need it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No big deal either way, it's a simple change and I'm just trying to sort out the conceptual boundaries for this thing.
if we will want to keep condensers separate or trigger them from here
I expect it might be the latter, but I need to ponder for a bit. Might try a refactor if there's time this weekend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the refactor away from message_utils.py
, and it'll be good to have a conceptual place for managing the conversation.
I'm curious about the "memory" part of the name -- is this a holdover from the original PR or is there some state we plan on storing in the ConversationMemory
? I can imagine an API whereby the ConversationMemory
object takes in a state and parses all the necessary deltas to build an up-to-date conversation, but outside of the context window truncation I think that's already the State.history
.
Co-authored-by: Calvin Smith <[email protected]>
It's minor and yet, encapsulation helps my slow brain 😊, and it has the right place I feel: linked to the agent, with all the agent has available, but cut off from the stream, and dealing with our event -> message issues.
You're right it's a holdover, but I kinda like it... I do feel we could look at it differently than the Memory component proposed there though:
Please tell if this naive story makes sense: 🤔 Or to put it differently, the user and the agent/llm have a conversation:
[1] it can include templating stuff) |
…t-conversation-memory
Hi! I started running the integration tests on your PR. You will receive a comment with the results shortly. |
Trigger by: Pull Request (integration-test label on PR #7008) Total cost: USD 0.11
Integration Tests Report (DeepSeek) Total cost: USD 0.01
Integration Tests Report Delegator (Haiku) Total cost: USD 0.06
Integration Tests Report Delegator (DeepSeek) Total cost: USD 0.00
Integration Tests Report VisualBrowsing (DeepSeek) Total cost: USD 0.00
Download testing outputs (includes both Haiku and DeepSeek results): Download |
Running evaluation on the PR. Once eval is done, the results will be posted. |
Evaluation results (Auto Reply): ## Summary
|
These are different instance ids since a PR earlier today. I don't see suspicious misses in the logs. Local eval works and has the prompts. |
This PR proposes a
ConversationMemory
class, a partial refactoring ofmessage_utils.py
, which is:state.history
, can keep an instance of the agent'sPromptManager
)history
, e.g.history
and it doesn't modify itIn the PR Add RecallObservations for retrieval of prompt extensions, I hit the fact that the conversion
event->message
needsPromptManager
templates forRecallObservations
(example), so the options we have there seem to be: to send aPromptManager
to the utils functions, or this PR (simple refactoring at the moment into an agent helper collaborating with the other agent helper, PromptManager)The code isn't doing much, just refactor to encapsulate the
message_utils
functions that work on agent history.openhands
description:This PR backports the conversation_memory.py class and related changes from PR #6909.
Changes included:
This backport does not include RecallObservations or any changes to prompt_manager.py as requested.
To run this PR locally, use the following command: