Skip to content

AI request timeout too short / not configurable, and failures logged without an error message #321

Description

@AhmetTumis

AI API requests use a hardcoded 120s httpx timeout, which kills long running local/api model generations even while it still actively produces tokens.
Split the timeout (connect/write/pool short, read raised to 600s) as a quick fix, but it should be a config entry instead of hardcoded:

@staticmethod
async def do_request(url: str, headers: dict, payload: dict):
    async def _fetch():
        timeout = httpx.Timeout(connect=10, read=600, write=10, pool=10)
        async with httpx.AsyncClient(timeout=timeout) as client:
            return await client.post(url, headers=headers, json=payload)

Additionally, failures are logged with no useful message, logging.error(f"Request failed: {error}") relies on str(exception), which is empty for httpx timeout exceptions, so the terminal just shows Request failed: with nothing after it. Should log repr(error) (or the exception type name) instead so the actual failure reason is visible.

Sources: hanfor/ai_request/api_request_methods/standard_ai_api.py (timeout, line 18; error logging, line 77)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions