|
|
@@ -1,4 +1,5 @@
|
|
|
import asyncio
|
|
|
+import copy
|
|
|
import traceback
|
|
|
from typing import Type
|
|
|
|
|
|
@@ -36,6 +37,7 @@ from openhands.events.observation import (
|
|
|
ErrorObservation,
|
|
|
Observation,
|
|
|
)
|
|
|
+from openhands.events.serialization.event import truncate_content
|
|
|
from openhands.llm.llm import LLM
|
|
|
from openhands.runtime.utils.shutdown_listener import should_continue
|
|
|
|
|
|
@@ -220,7 +222,13 @@ class AgentController:
|
|
|
):
|
|
|
return
|
|
|
|
|
|
- logger.info(observation, extra={'msg_type': 'OBSERVATION'})
|
|
|
+ # Make sure we print the observation in the same way as the LLM sees it
|
|
|
+ observation_to_print = copy.deepcopy(observation)
|
|
|
+ if len(observation_to_print.content) > self.agent.llm.config.max_message_chars:
|
|
|
+ observation_to_print.content = truncate_content(
|
|
|
+ observation_to_print.content, self.agent.llm.config.max_message_chars
|
|
|
+ )
|
|
|
+ logger.info(observation_to_print, extra={'msg_type': 'OBSERVATION'})
|
|
|
if self._pending_action and self._pending_action.id == observation.cause:
|
|
|
self._pending_action = None
|
|
|
if self.state.agent_state == AgentState.USER_CONFIRMED:
|