|
|
@@ -6,9 +6,9 @@ from opendevin.controller.agent import Agent
|
|
|
from opendevin.controller.state.state import State
|
|
|
from opendevin.core.config import config
|
|
|
from opendevin.core.exceptions import (
|
|
|
- AgentMalformedActionError,
|
|
|
- AgentNoActionError,
|
|
|
- LLMOutputError,
|
|
|
+ LLMMalformedActionError,
|
|
|
+ LLMNoActionError,
|
|
|
+ LLMResponseError,
|
|
|
MaxCharsExceedError,
|
|
|
)
|
|
|
from opendevin.core.logger import opendevin_logger as logger
|
|
|
@@ -113,6 +113,13 @@ class AgentController:
|
|
|
await self.set_agent_state_to(AgentState.ERROR)
|
|
|
|
|
|
async def report_error(self, message: str, exception: Exception | None = None):
|
|
|
+ """
|
|
|
+ This error will be reported to the user and sent to the LLM next step, in the hope it can self-correct.
|
|
|
+
|
|
|
+ This method should be called for a particular type of errors:
|
|
|
+ - the string message should be user-friendly, it will be shown in the UI
|
|
|
+ - an ErrorObservation can be sent to the LLM by the agent, with the exception message, so it can self-correct next time
|
|
|
+ """
|
|
|
self.state.error = message
|
|
|
if exception:
|
|
|
self.state.error += f': {str(exception)}'
|
|
|
@@ -293,8 +300,10 @@ class AgentController:
|
|
|
try:
|
|
|
action = self.agent.step(self.state)
|
|
|
if action is None:
|
|
|
- raise AgentNoActionError('No action was returned')
|
|
|
- except (AgentMalformedActionError, AgentNoActionError, LLMOutputError) as e:
|
|
|
+ raise LLMNoActionError('No action was returned')
|
|
|
+ except (LLMMalformedActionError, LLMNoActionError, LLMResponseError) as e:
|
|
|
+ # report to the user
|
|
|
+ # and send the underlying exception to the LLM for self-correction
|
|
|
await self.report_error(str(e))
|
|
|
return
|
|
|
|