Skip to content

Commit 5ee642e

Browse files
authored
Merge pull request #2057 from codeflash-ai/fix/api-read-timeout
fix: increase API read timeout to prevent flaky E2E failures
2 parents 72a41a5 + 4ac573f commit 5ee642e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

codeflash/api/aiservice.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def __init__(self) -> None:
4747
self.headers = {"Authorization": f"Bearer {get_codeflash_api_key()}", "Connection": "close"}
4848
self.llm_call_counter = count(1)
4949
self.is_local = self.base_url == "http://localhost:8000"
50-
self.timeout: float | None = 300 if self.is_local else 90
50+
# (connect_timeout, read_timeout) — connect should be fast; read
51+
# can be slow because the server runs LLM inference.
52+
self.timeout: float | tuple[float, float] | None = (10, 300)
5153

5254
def get_next_sequence(self) -> int:
5355
"""Get the next LLM call sequence number."""
@@ -88,7 +90,7 @@ def make_ai_service_request(
8890
endpoint: str,
8991
method: str = "POST",
9092
payload: dict[str, Any] | list[dict[str, Any]] | None = None,
91-
timeout: float | None = None,
93+
timeout: float | tuple[float, float] | None = None,
9294
) -> requests.Response:
9395
"""Make an API request to the given endpoint on the AI service.
9496

0 commit comments

Comments
 (0)