OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

feature: Condenser Interface and Defaults

Open csmith49 opened this issue 1 year ago • 1 comments

End-user friendly description of the problem this fixes or functionality that this introduces

  • [ ] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

Give a summary of what the PR does, explaining any non-trivial design decisions

This PR adds an abstract memory condenser interface, provides a few default condenser implementations, and updates the CodeActAgent to use the configured condenser during inference.

Condensers exist to reduce the size of the state that must be considered during an agent's step function. They provide a condense: list[Event] -> list[Event] function that can perform an arbitrary transformation on the history of a state before it is seen by an agent, including:

  • Summarizing the history in a new event (as in the LLMCondenser),
  • Removing old events (as in the `RecentEventsCondenser), or
  • Returning the history as-is (as in the NoOpCondenser).

This does not change the underlying state, but can be used by agents as a form of attention and to manage the size of the context in long-running jobs. For an example, see the implementation in CodeActAgent -- the default condenser is the NoOpCondenser, so while the agent is "using the condenser" there is no visible change unless otherwise configured. Currently, condensers must be set by manually initializing an AgentConfig object.

The intent of this PR is to lay the groundwork for an evaluation framework that will let us assess the efficacy of different condenser implementations and, if warranted, support switching between condensers with simple configuration options.

Link of any specific issues this addresses

csmith49 avatar Nov 27 '24 21:11 csmith49