fix agent inference timeout on slow local models
This commit is contained in:
@@ -14,11 +14,27 @@ if not os.environ.get("SOVEREIGNAI_DATA_DIR"):
|
||||
os.environ["SOVEREIGNAI_DATA_DIR"] = _TEST_DATA_DIR.name
|
||||
|
||||
from app import database
|
||||
from app.main import AgentRequest, run_agent_stream
|
||||
from app.main import AgentRequest, _execute_agent, run_agent_stream
|
||||
from app.model_provider import OllamaProvider
|
||||
|
||||
|
||||
class TimeoutAndCancellationTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_agent_model_calls_use_ten_minute_timeout(self) -> None:
|
||||
observed_timeouts: list[float] = []
|
||||
|
||||
async def fake_completion(_payload, *, timeout_seconds=180.0):
|
||||
observed_timeouts.append(timeout_seconds)
|
||||
return {"choices": [{"message": {"content": "تم"}}]}
|
||||
|
||||
with (
|
||||
patch("app.main.get_completion", side_effect=fake_completion),
|
||||
patch("app.main.workspace.selected_root", return_value=None),
|
||||
):
|
||||
result = await _execute_agent(AgentRequest(task="اشرح لي الفكرة"))
|
||||
|
||||
self.assertEqual(result["result"], "تم")
|
||||
self.assertEqual(observed_timeouts, [600.0])
|
||||
|
||||
async def test_provider_timeout_is_bounded_and_reported_as_504(self) -> None:
|
||||
observed_timeouts: list[float] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user