Request Timeout AI-Gateway: Error Code A1000

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Hello,

I'm using the Gitlab Duo Chat feature from gitlab 17.2

I usually have the Error Code A1000 which according to the documentation (https://docs.gitlab.com/ee/user/gitlab_duo_chat/troubleshooting.html#error-a1000) says that here is a connection error during processing.

As for me, this is a request timeout. 30s after asking the request to the feature, the error appears (if the time to "think" for the llm is above 30s)

I'm sure that come from the model-gateway:gitlab-v17.2.0 but I don't know how to modify this parameter.

Here is the logs of the gateway:

{"correlation_id": "01J3MXK7J63702Y13AQB2X63PT", "logger": "codesuggestions", "level": "critical", "type": "mlops", "stage": "main", "timestamp": "2024-07-25T12:24:31.966877Z", "message": "Auth is disabled, all users allowed"}
{"correlation_id": "01J3MXK7J63702Y13AQB2X63PT", "logger": "httpx", "level": "info", "type": "mlops", "stage": "main", "timestamp": "2024-07-25T12:24:32.126803Z", "message": "HTTP Request: POST http://litellm:4000/chat/completions \"HTTP/1.1 200 OK\""}
{"url": "http://gateway:5052/v1/chat/agent", "path": "/v1/chat/agent", "status_code": 200, "method": "POST", "correlation_id": "01J3MXK7J63702Y13AQB2X63PT", "http_version": "1.1", "client_ip": "172.18.0.3", "client_port": 32778, "duration_s": 0.17764729200098373, "duration_request": 0.024317026138305664, "cpu_s": 0.04965692500000074, "user_agent": "Ruby", "gitlab_instance_id": "bc46552a-806a-43b1-b7f9-556ac91385d9", "gitlab_global_user_id": "u7kh9IIHMFc/PlzXZJPrfuN4W/sCBYR4K3m5Cxtw2PY=", "gitlab_host_name": "gitlab", "gitlab_version": "17.2.0", "gitlab_saas_duo_pro_namespace_ids": null, "gitlab_saas_namespace_ids": null, "gitlab_realm": "self-managed", "meta.feature_category": "duo_chat", "logger": "api.access", "level": "info", "type": "mlops", "stage": "main", "timestamp": "2024-07-25T12:24:32.130533Z", "message": "172.18.0.3:32778 - \"POST /v1/chat/agent HTTP/1.1\" 200"}
{"correlation_id": "01J3MXK7J63702Y13AQB2X63PT", "logger": "uvicorn.error", "level": "error", "type": "mlops", "stage": "main", "timestamp": "2024-07-25T12:25:02.162841Z", "message": "Exception in ASGI application\n", "exception": "Traceback (most recent call last):\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py\", line 69, in map_httpcore_exceptions\n    yield\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py\", line 254, in __aiter__\n    async for part in self._httpcore_stream:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py\", line 367, in __aiter__\n    raise exc from None\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py\", line 363, in __aiter__\n    async for part in self._stream:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py\", line 349, in __aiter__\n    raise exc\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py\", line 341, in __aiter__\n    async for chunk in self._connection._receive_response_body(**kwargs):\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py\", line 210, in _receive_response_body\n    event = await self._receive_event(timeout=timeout)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_async/http11.py\", line 224, in _receive_event\n    data = await self._network_stream.read(\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_backends/anyio.py\", line 32, in read\n    with map_exceptions(exc_map):\n  File \"/usr/local/lib/python3.10/contextlib.py\", line 153, in __exit__\n    self.gen.throw(typ, value, traceback)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpcore/_exceptions.py\", line 14, in map_exceptions\n    raise to_exc(exc) from exc\nhttpcore.ReadTimeout\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 399, in run_asgi\n    result = await app(  # type: ignore[func-returns-value]\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py\", line 70, in __call__\n    return await self.app(scope, receive, send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/applications.py\", line 1054, in __call__\n    await super().__call__(scope, receive, send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/applications.py\", line 123, in __call__\n    await self.middleware_stack(scope, receive, send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py\", line 186, in __call__\n    raise exc\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py\", line 164, in __call__\n    await self.app(scope, receive, _send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/prometheus_fastapi_instrumentator/middleware.py\", line 174, in __call__\n    raise exc\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/prometheus_fastapi_instrumentator/middleware.py\", line 172, in __call__\n    await self.app(scope, receive, send_wrapper)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/asgi_correlation_id/middleware.py\", line 90, in __call__\n    await self.app(scope, receive, handle_outgoing_request)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette_context/middleware/raw_middleware.py\", line 92, in __call__\n    await self.app(scope, receive, send_wrapper)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/cors.py\", line 85, in __call__\n    await self.app(scope, receive, send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py\", line 189, in __call__\n    with collapse_excgroups():\n  File \"/usr/local/lib/python3.10/contextlib.py\", line 153, in __exit__\n    self.gen.throw(typ, value, traceback)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/_utils.py\", line 93, in collapse_excgroups\n    raise exc\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/responses.py\", line 261, in wrap\n    await func()\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py\", line 217, in stream_response\n    return await super().stream_response(send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/responses.py\", line 250, in stream_response\n    async for chunk in self.body_iterator:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py\", line 181, in body_stream\n    raise app_exc\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py\", line 151, in coro\n    await self.app(scope, receive_or_disconnect, send_no_error)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/authentication.py\", line 49, in __call__\n    await self.app(scope, receive, send)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py\", line 189, in __call__\n    with collapse_excgroups():\n  File \"/usr/local/lib/python3.10/contextlib.py\", line 153, in __exit__\n    self.gen.throw(typ, value, traceback)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/_utils.py\", line 93, in collapse_excgroups\n    raise exc\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/responses.py\", line 261, in wrap\n    await func()\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/responses.py\", line 250, in stream_response\n    async for chunk in self.body_iterator:\n  File \"/app/ai_gateway/api/v1/chat/agent.py\", line 156, in _stream_generator\n    async for result in response:\n  File \"/app/ai_gateway/models/litellm.py\", line 130, in _handle_stream\n    async for chunk in response:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/litellm/utils.py\", line 9781, in __anext__\n    raise e\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/litellm/utils.py\", line 9631, in __anext__\n    async for chunk in self.completion_stream:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/openai/_streaming.py\", line 147, in __aiter__\n    async for item in self._iterator:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/openai/_streaming.py\", line 160, in __stream__\n    async for sse in iterator:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/openai/_streaming.py\", line 151, in _iter_events\n    async for sse in self._decoder.aiter_bytes(self.response.aiter_bytes()):\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/openai/_streaming.py\", line 302, in aiter_bytes\n    async for chunk in self._aiter_chunks(iterator):\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/openai/_streaming.py\", line 313, in _aiter_chunks\n    async for chunk in iterator:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_models.py\", line 929, in aiter_bytes\n    async for raw_bytes in self.aiter_raw():\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_models.py\", line 987, in aiter_raw\n    async for raw_stream_bytes in self.stream:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_client.py\", line 149, in __aiter__\n    async for chunk in self._stream:\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py\", line 253, in __aiter__\n    with map_httpcore_exceptions():\n  File \"/usr/local/lib/python3.10/contextlib.py\", line 153, in __exit__\n    self.gen.throw(typ, value, traceback)\n  File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py\", line 86, in map_httpcore_exceptions\n    raise mapped_exc(message) from exc\nhttpx.ReadTimeout"}

Do you have any idea ?

Thanks !

Edited Sep 25, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading