Skip to content

Commit

Permalink
add error obs to codeact SWE (#3392)
Browse files Browse the repository at this point in the history
  • Loading branch information
enyst committed Aug 14, 2024
1 parent 4095a7d commit 463c66a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions agenthub/codeact_swe_agent/codeact_swe_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
CmdOutputObservation,
IPythonRunCellObservation,
)
from opendevin.events.observation.error import ErrorObservation
from opendevin.events.observation.observation import Observation
from opendevin.events.serialization.event import truncate_content
from opendevin.llm.llm import LLM
Expand Down Expand Up @@ -66,7 +67,7 @@ def __init__(
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
Expand Down Expand Up @@ -122,7 +123,14 @@ def get_observation_message(self, obs: Observation) -> Message | None:
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."""
Expand Down

0 comments on commit 463c66a

Please sign in to comment.