Closed as not planned
Description
Please read this first
- Have you read the docs?Agents SDK docs
Yes, I'm dealing with the first example in the docs. - Have you searched for related issues? Others may have had similar requests
I found there existed a similar problem in The handshake operation timed out - On requests https requests encode/httpx#1433, but the discussion didn't help me cause I couldn't edit the code of the library.
Question
Greetings!
I'm running an example provided in the github page:
import asyncio
from agents import Agent, Runner, function_tool
from dotenv import load_dotenv
@function_tool
def get_weather(city: str) -> str:
return f"The weather in {city} is sunny."
agent = Agent(
name="Hello world",
instructions="You are a helpful agent.",
tools=[get_weather],
)
async def main():
result = await Runner.run(agent, input="What's the weather in Tokyo?")
print(result.final_output)
# The weather in Tokyo is sunny.
if __name__ == "__main__":
load_dotenv()
asyncio.run(main())
In the code, load_dotenv()
loaded OPENAI_API_KEY
to my environment, and it worked fine. After that, the code raised an error:
Error getting response: Request timed out.. (request_id: None)
Traceback (most recent call last):
...
httpcore.ConnectTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
...
httpx.ConnectTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
...
File "/Users/jrx/miniconda3/lib/python3.12/site-packages/openai/_base_client.py", line 1748, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jrx/miniconda3/lib/python3.12/site-packages/openai/_base_client.py", line 1508, in request
raise APITimeoutError(request=request) from err
openai.APITimeoutError: Request timed out.
[non-fatal] Tracing: request failed: _ssl.c:983: The handshake operation timed out
[non-fatal] Tracing: request failed: _ssl.c:983: The handshake operation timed out
[non-fatal] Tracing: request failed: _ssl.c:983: The handshake operation timed out
[non-fatal] Tracing: max retries reached, giving up on this batch.
It just looked like a network issue, but I could ping openai.com
, and my network worked fine when I tried to access the webpage of ChatGPT.
Thanks!