π OpenHands: AI-Driven Development
Make max_iterations configurable (#676)
Engel Nyst66031a67ba86
diff --git a/opendevin/config.py b/opendevin/config.pyindex 187efdb614..4598fc25f0 100644--- a/opendevin/config.py+++ b/opendevin/config.py@@ -17,6 +17,7 @@ DEFAULT_CONFIG = {"LLM_COOLDOWN_TIME" : 1,"DIRECTORY_REWRITE" : "","PROMPT_DEBUG_DIR": "",+ "MAX_ITERATIONS": 100,}config_str = ""diff --git a/opendevin/controller/agent_controller.py b/opendevin/controller/agent_controller.pyindex 466bf86782..ab28a42a18 100644--- a/opendevin/controller/agent_controller.py+++ b/opendevin/controller/agent_controller.py@@ -29,6 +29,7 @@ from .command_manager import CommandManagerColorType = Literal['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'light_grey', 'dark_grey', 'light_red', 'light_green', 'light_yellow', 'light_blue', 'light_magenta', 'light_cyan', 'white']DISABLE_COLOR_PRINTING = config.get_or_default("DISABLE_COLOR", "false").lower() == "true"+MAX_ITERATIONS = config.get("MAX_ITERATIONS")def print_with_color(text: Any, print_type: str = "INFO"):TYPE_TO_COLOR: Mapping[str, ColorType] = {@@ -54,7 +55,7 @@ class AgentController:self,agent: Agent,workdir: str,- max_iterations: int = 100,+ max_iterations: int = MAX_ITERATIONS,container_image: str | None = None,callbacks: List[Callable] = [],):diff --git a/opendevin/main.py b/opendevin/main.pyindex 9c5637599a..e7cffbd617 100644--- a/opendevin/main.py+++ b/opendevin/main.py@@ -26,7 +26,7 @@ def parse_arguments():parser.add_argument("-f", "--file", type=str, help="Path to a file containing the task. Overrides -t if both are provided.")parser.add_argument("-c", "--agent-cls", default="MonologueAgent", type=str, help="The agent class to use")parser.add_argument("-m", "--model-name", default=config.get("LLM_MODEL"), type=str, help="The (litellm) model name to use")- parser.add_argument("-i", "--max-iterations", default=100, type=int, help="The maximum number of iterations to run the agent")+ parser.add_argument("-i", "--max-iterations", default=config.get("MAX_ITERATIONS"), type=int, help="The maximum number of iterations to run the agent")return parser.parse_args()async def main():diff --git a/opendevin/server/session.py b/opendevin/server/session.pyindex 9b9ed43fc5..06c31a53a9 100644--- a/opendevin/server/session.py+++ b/opendevin/server/session.py@@ -20,6 +20,7 @@ DEFAULT_BASE_URL = config.get("LLM_BASE_URL")DEFAULT_WORKSPACE_DIR = config.get("WORKSPACE_DIR")LLM_MODEL = config.get("LLM_MODEL")CONTAINER_IMAGE = config.get("SANDBOX_CONTAINER_IMAGE")+MAX_ITERATIONS = config.get("MAX_ITERATIONS")class Session:"""Represents a session with an agent.@@ -124,7 +125,7 @@ class Session:container_image = CONTAINER_IMAGEif start_event and "container_image" in start_event["args"]:container_image = start_event["args"]["container_image"]- max_iterations = 100+ max_iterations = MAX_ITERATIONSif start_event and "max_iterations" in start_event["args"]:max_iterations = start_event["args"]["max_iterations"]if not os.path.exists(directory):