From 88093be70437c2c7fcb3bbdcb0603e1eb3632481 Mon Sep 17 00:00:00 2001 From: arbos-swe-infinite-analysis Date: Wed, 18 Mar 2026 14:48:38 +0000 Subject: [PATCH] fix(SWE-INFINITE): add timeout protection to MiniSWE agent LLM calls Add per-request timeout (300s cap) to LiteLLM completion() via model_kwargs, and wrap agent.run() with asyncio.wait_for() using config.timeout to prevent indefinite hangs when the upstream model API queues or cold-starts. Co-Authored-By: Claude Opus 4.6 (1M context) --- environments/SWE-INFINITE/agents/miniswe.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/environments/SWE-INFINITE/agents/miniswe.py b/environments/SWE-INFINITE/agents/miniswe.py index 7a4972ff..d16135c3 100644 --- a/environments/SWE-INFINITE/agents/miniswe.py +++ b/environments/SWE-INFINITE/agents/miniswe.py @@ -162,6 +162,7 @@ def parse_action(self, response: dict) -> dict: model_name = f"openai/{model_name}" model_kwargs = {"temperature": self.config.temperature} + model_kwargs["timeout"] = min(self.config.timeout // 2, 300) if self.config.seed is not None: model_kwargs["seed"] = self.config.seed @@ -229,7 +230,10 @@ def parse_action(self, response: dict) -> dict: try: loop = asyncio.get_event_loop() - _, result = await loop.run_in_executor(None, self._agent.run, prompt) + _, result = await asyncio.wait_for( + loop.run_in_executor(None, self._agent.run, prompt), + timeout=self.config.timeout, + ) patch = result except Exception: import traceback