Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(llm): support draft editor retries by adding correct_num to LLMConfig (#11530)

Ray Myers450aa3b5279c
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(