You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot run the agent as it keeps raising the 'AsyncOpenAI' Object Has No Attribute 'responses' Error. Moreover, if I run the agent with run_sync, an error message 'this event loop is already running' shows.
Debug information
Agents SDK version: v0.0.11 (Also happens with v0.0.9)
OpenAI version: v1.75.0 (Also tried downgrading to v1.66.5, same issue happened)
Python version v3.12.4
Repro steps
class AgentRequest(BaseModel):
user_idea: str
@router.get("/begin_thinking", status_code=status.HTTP_200_OK)
async def begin_thinking(
topics: AgentRequest,
) -> JSONResponse:
try:
try:
agent = Agent(
name = "Testing Agent",
instructions="You are a cat, so you need to think like a cat and add cat emojis to your response."
)
except Exception as e:
raise Exception(f"Error in the agent creation: {e}")
logger.debug(f"Beginning thinking with topics: {topics.user_idea}")
try:
result = Runner.run_sync(
starting_agent=agent, input=topics.user_idea
)
except Exception as e:
raise Exception(f"Error in the agent run: {e}")
if not result:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="No results found")
return JSONResponse(
content={
"status": "success",
"data": result.final_output,
},
status_code=status.HTTP_200_OK,
)
except Exception as e:
logger.error(f"Error in running the agent: {e}")
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=f"Something went wrong while running the agent. {e}")
Logger Record When I use Runner.run()
DAOS DEBUG LOGS: 2025-04-18 08:48:18,133 - openai.agents - DEBUG - Creating trace Agent workflow with id trace_f73ee56d23f74f098d7990c3cdfc9336
DAOS DEBUG LOGS: 2025-04-18 08:48:18,133 - openai.agents - DEBUG - Setting current trace: trace_f73ee56d23f74f098d7990c3cdfc9336
DAOS DEBUG LOGS: 2025-04-18 08:48:18,133 - openai.agents - DEBUG - Creating span <agents.tracing.span_data.AgentSpanData object at 0xfffefbb6cf40> with id None
DAOS DEBUG LOGS: 2025-04-18 08:48:18,133 - openai.agents - DEBUG - Running agent Testing Agent (turn 1)
DAOS DEBUG LOGS: 2025-04-18 08:48:18,137 - openai.agents - DEBUG - Creating span <agents.tracing.span_data.ResponseSpanData object at 0xfffefbf991c0> with id None
DAOS DEBUG LOGS: 2025-04-18 08:48:18,138 - openai.agents - DEBUG - Calling LLM gpt-4o with input:
[
{
"content": "The history of train",
"role": "user"
}
]
Tools:
[]
Stream: False
Tool choice: NOT_GIVEN
Response format: NOT_GIVEN
Previous response id: None
DAOS DEBUG LOGS: 2025-04-18 08:48:18,138 - openai.agents - ERROR - Error getting response: 'AsyncOpenAI' object has no attribute 'responses'. (request_id: None)
DAOS DEBUG LOGS: 2025-04-18 08:48:18,138 - openai.agents - DEBUG - Resetting current trace
DAOS DEBUG LOGS: 2025-04-18 08:48:18,139 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-4' coro=<Runner.run() done, defined at /usr/local/lib/python3.10/site-packages/agents/run.py:110> exception=AttributeError("'AsyncOpenAI' object has no attribute 'responses'")>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/agents/run.py", line 218, in run
input_guardrail_results, turn_result = await asyncio.gather(
File "/usr/local/lib/python3.10/site-packages/agents/run.py", line 756, in _run_single_turn
new_response = await cls._get_new_response(
File "/usr/local/lib/python3.10/site-packages/agents/run.py", line 915, in _get_new_response
new_response = await model.get_response(
File "/usr/local/lib/python3.10/site-packages/agents/models/openai_responses.py", line 76, in get_response
response = await self._fetch_response(
File "/usr/local/lib/python3.10/site-packages/agents/models/openai_responses.py", line 242, in _fetch_response
return await self._client.responses.create(
AttributeError: 'AsyncOpenAI' object has no attribute 'responses'
DAOS DEBUG LOGS: 2025-04-18 08:48:18,705 - httpcore.connection - DEBUG - connect_tcp.started host='api.openai.com' port=443 local_address=None timeout=5.0 socket_options=None
DAOS DEBUG LOGS: 2025-04-18 08:48:18,749 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0xfffefbb94430>
DAOS DEBUG LOGS: 2025-04-18 08:48:18,750 - httpcore.connection - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0xffff831baec0> server_hostname='api.openai.com' timeout=5.0
DAOS DEBUG LOGS: 2025-04-18 08:48:18,758 - httpcore.connection - DEBUG - start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0xfffefbb94400>
DAOS DEBUG LOGS: 2025-04-18 08:48:19,333 - httpx - INFO - HTTP Request: POST https://api.openai.com/v1/traces/ingest "HTTP/1.1 204 No Content"
DAOS DEBUG LOGS: 2025-04-18 08:48:19,334 - openai.agents - DEBUG - Exported 3 items
DAOS DEBUG LOGS: 2025-04-18 08:52:21,951 - openai.agents - DEBUG - Shutting down trace provider
DAOS DEBUG LOGS: 2025-04-18 08:52:21,952 - openai.agents - DEBUG - Shutting down trace processor <agents.tracing.processors.BatchTraceProcessor object at 0xffff83245b40>
Logger Record When I use Runner.run_sync() instead of Runner.run()
DAOS DEBUG LOGS: 2025-04-18 08:48:18,132 - app.routers.agentic_workflow - ERROR - Error in running the agent: Error in the agent run: this event loop is already running.
Expected behavior
The agent should run in both sync and async mode.
The text was updated successfully, but these errors were encountered:
Describe the bug
I cannot run the agent as it keeps raising the 'AsyncOpenAI' Object Has No Attribute 'responses' Error. Moreover, if I run the agent with run_sync, an error message 'this event loop is already running' shows.
Debug information
Repro steps
Logger Record When I use Runner.run()
Logger Record When I use Runner.run_sync() instead of Runner.run()
Expected behavior
The agent should run in both sync and async mode.
The text was updated successfully, but these errors were encountered: