fancy-salesmen-9987
08/19/2025, 2:18 PMreplay is not the right feature, since it does not condition the agent on the replayed trajectory and only re executes it.
My implementation loads messages from a previous trajectory into params['messages'] and updates state.history accordingly.
replay_events, initial_user_action = load_replay_log(
self.cfg.restore_trajectory_path
)
restored_history = replay_events
state.history = restored_history
replay_events.insert(
0, initial_user_action
) # Replay events does not include the first action we need to add it again
restored_messages = self._get_messages(
replay_events, initial_user_message
)
params['messages'] = self.llm.format_messages_for_llm(restored_messages)
After the final iteration of step(self, state: State), state.history contains both the restored trajectory and the new actions. However, at the end of run_controller https://github.com/All-Hands-AI/OpenHands/blob/0297b3da18bdaf64233641cc1b48900c3328cc3a/openhands/core/main.py#L230 controller.get_state() is called, which clears the history https://github.com/All-Hands-AI/OpenHands/blob/0297b3da18bdaf64233641cc1b48900c3328cc3a/openhands/controller/state/state.py#L194 The comment states that history is restored from event stream. I checked the event stream before the agent controller is closed, and it only contains the new actions, not the restored trajectory.
How can I add the restored trajectory to the event stream, or what would be the recommended approach? Thanks!calm-artist-7206
08/19/2025, 2:25 PMcalm-artist-7206
08/19/2025, 2:26 PMcalm-artist-7206
08/19/2025, 2:28 PMcalm-artist-7206
08/19/2025, 2:28 PMfancy-salesmen-9987
08/19/2025, 2:35 PMcalm-artist-7206
08/19/2025, 2:38 PMfancy-salesmen-9987
08/19/2025, 2:40 PMcalm-artist-7206
08/19/2025, 2:41 PMcalm-artist-7206
08/19/2025, 2:42 PMcalm-artist-7206
08/19/2025, 2:42 PMfancy-salesmen-9987
08/19/2025, 2:52 PMstate.history and observed that while the restored trajectory is represented in the history, the first action after the replay was independent of what happened before, i.e. it was a response to the initial prompt, not taking the trajectory into account. Then I checked what is actually passed to the model by inspecting params['messages'] and did not see the messages from the restored trajectory therecalm-artist-7206
08/19/2025, 3:07 PMcalm-artist-7206
08/19/2025, 3:12 PMcalm-artist-7206
08/19/2025, 3:15 PMcalm-artist-7206
08/19/2025, 3:15 PMcalm-artist-7206
08/19/2025, 3:17 PMmagnificent-hairdresser-38202
08/19/2025, 7:58 PMfancy-salesmen-9987
08/19/2025, 8:26 PMcalm-artist-7206
08/19/2025, 8:27 PM