OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Condensation request signal in event stream

Open csmith49 opened this issue 6 months ago • 1 comments

  • [ ] This change is worth documenting at https://docs.all-hands.dev/
  • [ ] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

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


Summarize what the PR does, explaining any non-trivial design decisions.

This PR adds a new event that represents a request for a condensation. This is intended to clean up the control flow of the agent controller by allowing us to use existing condensation implementations instead of the apply_conversation_window logic (which is a bit brittle and doesn't produce any kind of summary for the forgotten events).

To make this transition easier I've also added a condenser which applies precisely the logic from apply_conversation_window, but we can deprecate that in favor of a summarizing condenser at a later date.

(As a bonus, it becomes possible to trigger condensation with a tool call, meaning the agent can now choose to condense or can do so when requested by the user.)

The control flow of the condensation request looks a little like this:

  1. REQUEST 1: while taking a step, the agent throws some kind of exception in response to having too much context.
  2. The agent controller intercepts this exception and adds a CondensationRequestAction to the event stream. This triggers another step.
  3. REQUEST 2: another step, but with the condensation request now also in the context. This is caught by the condenser (which relies on the View object to see if there are any "hanging" requests while it processes the event stream), which will produce a CondensationAction instead of letting the agent pick the next action.
  4. The agent controller sees the condensation action and triggers another step.
  5. REQUEST 3: another step, but the View now processes the condensation and presents a smaller context to the agent.

Link of any specific issues this addresses:


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:c2f3da1-nikolaik   --name openhands-app-c2f3da1   docker.all-hands.dev/all-hands-ai/openhands:c2f3da1

csmith49 avatar Jun 12 '25 15:06 csmith49

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Docker

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #9097

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

openhands-ai[bot] avatar Jun 25 '25 19:06 openhands-ai[bot]

@csmith49 Just curious: I see enable_condensation_request is disabled by default. Has this option been ever evaluated? I feel like it might be useful for web browsing tasks.

li-boxuan avatar Sep 24 '25 05:09 li-boxuan