π OpenHands: AI-Driven Development
add error obs to codeact SWE (#3392)
Engel Nyst463c66a372e5
diff --git a/agenthub/codeact_swe_agent/codeact_swe_agent.py b/agenthub/codeact_swe_agent/codeact_swe_agent.pyindex b1191ff672..906bf258c3 100644--- a/agenthub/codeact_swe_agent/codeact_swe_agent.py+++ b/agenthub/codeact_swe_agent/codeact_swe_agent.py@@ -19,6 +19,7 @@ from opendevin.events.observation import (CmdOutputObservation,IPythonRunCellObservation,)+from opendevin.events.observation.error import ErrorObservationfrom opendevin.events.observation.observation import Observationfrom opendevin.events.serialization.event import truncate_contentfrom opendevin.llm.llm import LLM@@ -66,7 +67,7 @@ class CodeActSWEAgent(Agent):self,llm: LLM,) -> None:- """Initializes a new instance of the CodeActAgent class.+ """Initializes a new instance of the CodeActSWEAgent class.Parameters:- llm (LLM): The llm to be used by this agent@@ -122,7 +123,14 @@ class CodeActSWEAgent(Agent):text = '\n'.join(splitted)text = truncate_content(text, max_message_chars)return Message(role='user', content=[TextContent(text=text)])- return None+ elif isinstance(obs, ErrorObservation):+ text = 'OBSERVATION:\n' + truncate_content(obs.content, max_message_chars)+ text += '\n[Error occurred in processing last action]'+ return Message(role='user', content=[TextContent(text=text)])+ else:+ # If an observation message is not returned, it will cause an error+ # when the LLM tries to return the next message+ raise ValueError(f'Unknown observation type: {type(obs)}')def reset(self) -> None:"""Resets the CodeAct Agent."""