enh: Refactor `Event` -> `Message` pipeline outside of `CodeActAgent`
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_contentdefault behavior - Moves
Messageconversion tests out oftest_codeact_agent.pyand intotest_message_utils.py - Refactor
CodeActAgent._get_messageswith two new private methods to encapsulate behavior
These changes enable us to:
- Move towards a uniform
Event->Messageconversion - 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.
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.