OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

enh: Refactor `Event` -> `Message` pipeline outside of `CodeActAgent`

Open csmith49 opened this issue 11 months 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 pulls the Event -> Message pipeline out of the CodeAct agent and into core.

Additionally:

  • Improvements to truncate_content default behavior
  • Moves Message conversion tests out of test_codeact_agent.py and into test_message_utils.py
  • Refactor CodeActAgent._get_messages with two new private methods to encapsulate behavior

These changes enable us to:

  • Move towards a uniform Event -> Message conversion
  • Simplify the CodeAct agent implementation
  • Compute message representations outside of the agent (useful for condensers and other "predictive" calculations)

Other agents don't use a similar pipeline: the browsing agents build messages manually from prompts, and the delegating agent just delegates.


Link of any specific issues this addresses

This PR is necessary to resolve #6707, as we need to compute the accurate message structure outside of the agent.

csmith49 avatar Feb 13 '25 19:02 csmith49

We can merge this, if you like to go this way. It's a small step, but it's nice how it clears the agent, too.

enyst avatar Feb 17 '25 22:02 enyst