urllib3.exceptions.ReadTimeoutError Causes api.py to raise exception "ERROR: Exception in ASGI application"
Describe the bug
During long Browser tool is working if the reply of the server times out, generates ReadTimeoutError, which looks allot like one of the other exceptions (ReadTimeoutError) already handled.
To Reproduce Use the browser tool to try to fetch an unreliable website.
Expected behavior
Not Exit when it times outs and give agentseek a chance to recover
TRACE
**** key exceptions excerpts from below: **** File "/home/gab/personal/agenticSeek/sources/agents/browser_agent.py", line 413, in process nav_ok = self.browser.go_to(link) File "/home/gab/personal/agenticSeek/sources/browser.py", line 299, in go_to raise e File "/home/gab/personal/agenticSeek/sources/browser.py", line 274, in go_to self.driver.get(url) ....... File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connectionpool.py", line 367, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=57535): Read timed out. (read timeout=120)
<------------------------------------------------>
*** Full Stacktrace ***
Exception in ASGI application Traceback (most recent call last): File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connectionpool.py", line 534, in _make_request response = conn.getresponse() File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connection.py", line 516, in getresponse httplib_response = super().getresponse() File "/home/gab/.conda/envs/py310/lib/python3.10/http/client.py", line 1375, in getresponse response.begin() File "/home/gab/.conda/envs/py310/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/home/gab/.conda/envs/py310/lib/python3.10/http/client.py", line 279, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/home/gab/.conda/envs/py310/lib/python3.10/socket.py", line 717, in readinto return self._sock.recv_into(b) TimeoutError: timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/gab/personal/agenticSeek/./api.py", line 207, in process_query success = await think_wrapper(interaction, request.query) File "/home/gab/personal/agenticSeek/./api.py", line 185, in think_wrapper raise e File "/home/gab/personal/agenticSeek/./api.py", line 170, in think_wrapper success = await interaction.think() File "/home/gab/personal/agenticSeek/sources/interaction.py", line 162, in think self.last_answer, self.last_reasoning = await agent.process(self.last_query, self.speech) File "/home/gab/personal/agenticSeek/sources/agents/planner_agent.py", line 283, in process raise e File "/home/gab/personal/agenticSeek/sources/agents/planner_agent.py", line 281, in process answer, success = await self.start_agent_process(task, required_infos) File "/home/gab/personal/agenticSeek/sources/agents/planner_agent.py", line 233, in start_agent_process answer, reasoning = await self.agents[task['agent'].lower()].process(agent_prompt, None) File "/home/gab/personal/agenticSeek/sources/agents/browser_agent.py", line 413, in process nav_ok = self.browser.go_to(link) File "/home/gab/personal/agenticSeek/sources/browser.py", line 299, in go_to raise e File "/home/gab/personal/agenticSeek/sources/browser.py", line 274, in go_to self.driver.get(url) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 472, in get self.execute(Command.GET, {"url": url}) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 445, in execute response = self.command_executor.execute(driver_command, params) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 404, in execute return self._request(command_info[0], url, body=data) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 428, in _request response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/_request_methods.py", line 143, in request return self.request_encode_body( File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/_request_methods.py", line 278, in request_encode_body return self.urlopen(method, url, **extra_kw) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/poolmanager.py", line 443, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connectionpool.py", line 841, in urlopen retries = retries.increment( File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/util/retry.py", line 474, in increment raise reraise(type(error), error, _stacktrace) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/util/util.py", line 39, in reraise raise value File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen response = self._make_request( File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connectionpool.py", line 536, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/urllib3/connectionpool.py", line 367, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=57535): Read timed out. (read timeout=120)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi result = await app( # type: ignore[func-returns-value] File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in call return await self.app(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/applications.py", line 112, in call await self.middleware_stack(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in call await self.app(scope, receive, _send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/middleware/cors.py", line 93, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/middleware/cors.py", line 144, in simple_response await self.app(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/routing.py", line 714, in call await self.middleware_stack(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/starlette/routing.py", line 73, in app response = await f(request) File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app raw_response = await run_endpoint_function( File "/home/gab/.conda/envs/py310/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function return await dependant.call(**values) File "/home/gab/personal/agenticSeek/./api.py", line 247, in process_query sys.exit(1) SystemExit: 1 INFO: 127.0.0.1:54894 - "POST /query HTTP/1.1" 500 Internal Server Error INFO: 127.0.0.1:39696 - "GET /health HTTP/1
LLM Model used DeepSeek-R1-Distill-Qwen-14B-f16.gguf
Desktop (please complete the following information):
- OS: Fedora Linux 42, Conda python environment with python 3.10
- Browser : Chrome 137.0.7151.103 (Official Build) (64-bit)
- Version [e.g. 22]
Additional context provider using llama.cpp through openai provider style API
This kind of sucks as the planner was running a complex task that was taking a couple of hours already on my modest A3000 gpu.
I have a small patch that may as well provide a way for it to continue by handling the ReadTimeoutError in the same fashion the other timeout exception is handled in the browser.py file
Yes, I am closing since it's specific to your network.
Feel free to do a pull request if you want to do share a small patch :)