8000 Failed to run the example in docs due to handshake operation time out · Issue #828 · openai/openai-agents-python · GitHub
[go: up one dir, main page]

Skip to content
Failed to run the example in docs due to handshake operation time out #828
Closed as not planned
@RuixiangJiang

Description

@RuixiangJiang

Please read this first

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDKstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0