From 450aa3b5279c6ee274ac1042acbed75286db0cda Mon Sep 17 00:00:00 2001 From: Ray Myers Date: Mon, 27 Oct 2025 20:02:50 -0500 Subject: [PATCH] fix(llm): support draft editor retries by adding correct_num to LLMConfig (#11530) Co-authored-by: openhands Co-authored-by: Justin Coffi --- openhands/core/config/llm_config.py | 2 ++ openhands/runtime/utils/edit.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openhands/core/config/llm_config.py b/openhands/core/config/llm_config.py index ecf316319c..56a93d2f85 100644 --- a/openhands/core/config/llm_config.py +++ b/openhands/core/config/llm_config.py @@ -95,6 +95,8 @@ class LLMConfig(BaseModel): description='Safety settings for models that support them (like Mistral AI and Gemini)', ) for_routing: bool = Field(default=False) + # The number of correction attempts for the LLM draft editor + correct_num: int = Field(default=5) completion_kwargs: dict[str, Any] | None = Field( default=None, description='Custom kwargs to pass to litellm.completion', diff --git a/openhands/runtime/utils/edit.py b/openhands/runtime/utils/edit.py index 692f0c3ace..7be5897ecf 100644 --- a/openhands/runtime/utils/edit.py +++ b/openhands/runtime/utils/edit.py @@ -400,8 +400,8 @@ class FileEditRuntimeMixin(FileEditRuntimeInterface): ret_obs.llm_metrics = self.draft_editor_llm.metrics return ret_obs - def check_retry_num(self, retry_num): - correct_num = self.draft_editor_llm.config.correct_num # type: ignore[attr-defined] + def check_retry_num(self, retry_num: int) -> bool: + correct_num = self.draft_editor_llm.config.correct_num return correct_num < retry_num def correct_edit(