Skip to content

404 Error During Agent Handoff in Multi-Agent System #206

Open
@BowenBryanWang

Description

@BowenBryanWang

Please read this first

  • Have you read the docs?Agents SDK docs Yes
  • Have you searched for related issues? Others may have faced similar issues.

Describe the bug

During execution of a multi-agent task, our system encountered a critical 404 error when attempting to process a function call between agents. The error occurred specifically when the General Agent tried to hand off to the Search Agent to find NBA finals results.

Debug information

  • Agents SDK version: v0.0.4
  • Python version: Python 3.9

Log


2025-03-17 19:22:38 - openai_agents_integration.py:724 - INFO - [{'content': 'can you help me search for the NBA finals result of last 5 years and then write the results in a new markdown file using MarkText, save it as "NBA.md"', 'role': 'user'}, {'id': 'fc_67d876754b2c8191bec6637d6c64a8d70ca151ec7ca34d36', 'arguments': '{}', 'call_id': 'call_Do6VuH7tpEBxBSoPuvACwDvo', 'name': 'transfer_to_search_agent', 'type': 'function_call', 'status': 'completed'}, {'id': 'fc_67d87675a94c81918773f9919a2b10b30ca151ec7ca34d36', 'arguments': '{}', 'call_id': 'call_S2ewJBvZ8bGaP5XcsQBiSLSZ', 'name': 'transfer_to_computer_agent', 'type': 'function_call', 'status': 'completed'}, {'call_id': 'call_S2ewJBvZ8bGaP5XcsQBiSLSZ', 'output': 'Multiple handoffs detected, ignoring this one.', 'type': 'function_call_output'}, {'call_id': 'call_Do6VuH7tpEBxBSoPuvACwDvo', 'output': "{'assistant': 'Search Agent'}", 'type': 'function_call_output'}]
2025-03-17 19:22:38 - openai_agents_integration.py:725 - INFO - Response(id='resp_67d8767667948191b587805df3631f820ca151ec7ca34d36', created_at=1742239350.0, error=None, incomplete_details=None, instructions="You are a searching agent connected to the Internet, you can help do information retrieval to gather useful information for the user's instruction. However, you cannot do any GUI actions on the computer unless you handoff the task to the Computer Agent.", metadata={}, model='gpt-4o-2024-08-06', object='response', output=[ResponseFunctionWebSearch(id='ws_67d87676eeac81918b0752e6fa32bc510ca151ec7ca34d36', status='completed', type='web_search_call'), ResponseOutputMessage(id='msg_67d8767987188191b9b16b6584c8f2280ca151ec7ca34d36', content=[ResponseOutputText(annotations=[], text='Here are the NBA Finals results from the past five years:\n\n| Year | Champion               | Series Result | Runner-Up         | Finals MVP             |\n|------|------------------------|---------------|-------------------|------------------------|\n| 2024 | Boston Celtics         | 4–1           | Dallas Mavericks  | Jaylen Brown           |\n| 2023 | Denver Nuggets         | 4–1           | Miami Heat        | Nikola Jokić           |\n| 2022 | Golden State Warriors  | 4–2           | Boston Celtics    | Stephen Curry          |\n| 2021 | Milwaukee Bucks        | 4–2           | Phoenix Suns      | Giannis Antetokounmpo  |\n| 2020 | Los Angeles Lakers     | 4–2           | Miami Heat        | LeBron James           |\n\nThese results highlight the competitive nature of the NBA over the past five seasons, with different teams achieving championship success each year. ', type='output_text')], role='assistant', status='completed', type='message'), ResponseFunctionToolCall(id='fc_67d8767bb470819190efb9fb355937970ca151ec7ca34d36', arguments='{}', call_id='call_Eb74hcO7M492eoQdIXRxxkyH', name='transfer_to_computer_agent', type='function_call', status='completed')], parallel_tool_calls=True, temperature=1.0, tool_choice='auto', tools=[FunctionTool(name='transfer_to_computer_agent', parameters={'additionalProperties': False, 'type': 'object', 'properties': {}, 'required': []}, strict=True, type='function', description='Handoff to the Computer Agent agent to handle the request. A real user computer environment to do GUI actions.'), WebSearchTool(type='web_search_preview', search_context_size='medium', user_location=UserLocation(type='approximate', city='New York', country=None, region=None, timezone=None))], top_p=1.0, max_output_tokens=None, previous_response_id=None, reasoning=Reasoning(effort=None, generate_summary=None), status='completed', text=ResponseTextConfig(format=ResponseFormatText(type='text')), truncation='disabled', usage=ResponseUsage(input_tokens=1265, output_tokens=228, output_tokens_details=OutputTokensDetails(reasoning_tokens=0), total_tokens=1493, input_tokens_details={'cached_tokens': 0}), user=None, store=False)

2025-03-17 19:22:36 - openai_agent.py:533 - ERROR - Error running OpenAI Agent: Error code: 404 - {'error': {'message': "Item with id 'fc_67d876754b2c8191bec6637d6c64a8d70ca151ec7ca34d36' not found.", 'type': 'invalid_request_error', 'param': 'input', 'code': None}}
Traceback (most recent call last):

  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/threading.py", line 937, in _bootstrap
    self._bootstrap_inner()
    │    └ <function Thread._bootstrap_inner at 0x77ae73f8fdc0>
    └ <DaemonThread(Thread-277, started daemon 131585582040640)>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
    │    └ <function Thread.run at 0x77ae73f8faf0>
    └ <DaemonThread(Thread-277, started daemon 131585582040640)>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {}
    │    │        │    │        └ <DaemonThread(Thread-277, started daemon 131585582040640)>
    │    │        │    └ (<socketio.server.Server object at 0x77ae71e04610>, 'dTs_zpIXxyXjfPalAAAd', '_hrfe3wpcicsAUcVAAAc', ['message', {'user_id': '...
    │    │        └ <DaemonThread(Thread-277, started daemon 131585582040640)>
    │    └ <bound method Server._handle_event_internal of <socketio.server.Server object at 0x77ae71e04610>>
    └ <DaemonThread(Thread-277, started daemon 131585582040640)>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/socketio/server.py", line 586, in _handle_event_internal
    r = server._trigger_event(data[0], namespace, sid, *data[1:])
        │      │              │        │          │     └ ['message', {'user_id': '62492e5d-2ed3-4469-91b1-1363cdbefeff', 'chat_id': 'cc2a679d-8050-4530-b5f9-3038f97f5719', 'user_inte...
        │      │              │        │          └ 'dTs_zpIXxyXjfPalAAAd'
        │      │              │        └ '/'
        │      │              └ ['message', {'user_id': '62492e5d-2ed3-4469-91b1-1363cdbefeff', 'chat_id': 'cc2a679d-8050-4530-b5f9-3038f97f5719', 'user_inte...
        │      └ <function Server._trigger_event at 0x77ae71e78820>
        └ <socketio.server.Server object at 0x77ae71e04610>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/socketio/server.py", line 611, in _trigger_event
    return handler(*args)
           │        └ ('dTs_zpIXxyXjfPalAAAd', {'user_id': '62492e5d-2ed3-4469-91b1-1363cdbefeff', 'chat_id': 'cc2a679d-8050-4530-b5f9-3038f97f5719...
           └ <function handle_message at 0x77ad466cb5e0>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/flask_socketio/__init__.py", line 282, in _handler
    return self._handle_event(handler, message, namespace, sid,
           │    │             │        │        │          └ 'dTs_zpIXxyXjfPalAAAd'
           │    │             │        │        └ '/'
           │    │             │        └ 'message'
           │    │             └ <function handle_message at 0x77ad466c2af0>
           │    └ <function SocketIO._handle_event at 0x77ae71df3a60>
           └ <flask_socketio.SocketIO object at 0x77ae71e04220>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/flask_socketio/__init__.py", line 827, in _handle_event
    ret = handler(*args)
          │        └ ({'user_id': '62492e5d-2ed3-4469-91b1-1363cdbefeff', 'chat_id': 'cc2a679d-8050-4530-b5f9-3038f97f5719', 'user_intent': 'can y...
          └ <function handle_message at 0x77ad466c2af0>

  File "/home/ubuntu/workspace/VLMAgentArena/backend/api/conversation.py", line 35, in handle_message
    return loop.run_until_complete(async_handle_message(json))
           │    │                  │                    └ {'user_id': '62492e5d-2ed3-4469-91b1-1363cdbefeff', 'chat_id': 'cc2a679d-8050-4530-b5f9-3038f97f5719', 'user_intent': 'can yo...
           │    │                  └ <function async_handle_message at 0x77ad5749daf0>
           │    └ <function BaseEventLoop.run_until_complete at 0x77ae728301f0>
           └ <_UnixSelectorEventLoop running=True closed=False debug=False>

  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/asyncio/base_events.py", line 634, in run_until_complete
    self.run_forever()
    │    └ <function BaseEventLoop.run_forever at 0x77ae72830160>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/asyncio/base_events.py", line 601, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x77ae72832ca0>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/asyncio/base_events.py", line 1905, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x77ae7286e310>
    └ <Handle <TaskStepMethWrapper object at 0x77ad40ecd790>()>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle <TaskStepMethWrapper object at 0x77ad40ecd790>()>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle <TaskStepMethWrapper object at 0x77ad40ecd790>()>
    │    └ <member '_context' of 'Handle' objects>
    └ <Handle <TaskStepMethWrapper object at 0x77ad40ecd790>()>

  File "/home/ubuntu/workspace/VLMAgentArena/backend/api/conversation.py", line 293, in execute_agent
    return await agent.run(task_instruction=task_instruction)
                 │     │                    └ 'can you help me search for the NBA finals result of last 5 years and then write the results in a new markdown file using Mar...
                 │     └ <function OpenAIAgentWrapper.run at 0x77ad45966940>
                 └ <backend.agents.hub.OpenAIAgents.openai_agent.OpenAIAgentWrapper object at 0x77ad4cd66b20>

  File "/home/ubuntu/workspace/VLMAgentArena/backend/agents/BaseAgent.py", line 150, in async_wrapper
    result = await func(self, *args, **kwargs)
                   │    │      │       └ {'task_instruction': 'can you help me search for the NBA finals result of last 5 years and then write the results in a new ma...
                   │    │      └ ()
                   │    └ <backend.agents.hub.OpenAIAgents.openai_agent.OpenAIAgentWrapper object at 0x77ad4cd66b20>
                   └ <function OpenAIAgentWrapper.run at 0x77ad459668b0>

> File "/home/ubuntu/workspace/VLMAgentArena/backend/agents/hub/OpenAIAgents/openai_agent.py", line 525, in run
    self.last_result = await Runner.run(self.openai_agent, task_instruction)
    │    │                   │      │   │    │             └ 'can you help me search for the NBA finals result of last 5 years and then write the results in a new markdown file using Mar...
    │    │                   │      │   │    └ Agent(name='General Agent', instructions=("You are a general digital agent. Your task is to help understand the user's instru...
    │    │                   │      │   └ <backend.agents.hub.OpenAIAgents.openai_agent.OpenAIAgentWrapper object at 0x77ad4cd66b20>
    │    │                   │      └ <classmethod object at 0x77ad459a8bb0>
    │    │                   └ <class 'agents.run.Runner'>
    │    └ None
    └ <backend.agents.hub.OpenAIAgents.openai_agent.OpenAIAgentWrapper object at 0x77ad4cd66b20>

  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/agents/run.py", line 229, in run
    turn_result = await cls._run_single_turn(
                        │   └ <classmethod object at 0x77ad459a8b80>
                        └ <class 'agents.run.Runner'>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/agents/run.py", line 719, in _run_single_turn
    new_response = await cls._get_new_response(
                         │   └ <classmethod object at 0x77ad459a8af0>
                         └ <class 'agents.run.Runner'>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/agents/run.py", line 862, in _get_new_response
    new_response = await model.get_response(
                         │     └ <function OpenAIResponsesModel.get_response at 0x77ad459f95e0>
                         └ <agents.models.openai_responses.OpenAIResponsesModel object at 0x77ad404531c0>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/agents/models/openai_responses.py", line 75, in get_response
    response = await self._fetch_response(
                     │    └ <function OpenAIResponsesModel._fetch_response at 0x77ad459f9700>
                     └ <agents.models.openai_responses.OpenAIResponsesModel object at 0x77ad404531c0>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/agents/models/openai_responses.py", line 230, in _fetch_response
    return await self._client.responses.create(
                 │    │       │         └ <function AsyncResponses.create at 0x77ad4d0d9550>
                 │    │       └ <openai.resources.responses.responses.AsyncResponses object at 0x77ad4044d970>
                 │    └ <openai.AsyncOpenAI object at 0x77ad47eb2730>
                 └ <agents.models.openai_responses.OpenAIResponsesModel object at 0x77ad404531c0>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/openai/resources/responses/responses.py", line 1414, in create
    return await self._post(
                 │    └ <bound method AsyncAPIClient.post of <openai.AsyncOpenAI object at 0x77ad47eb2730>>
                 └ <openai.resources.responses.responses.AsyncResponses object at 0x77ad4044d970>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/openai/_base_client.py", line 1767, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
                 │    │       │        │            │                  └ openai.AsyncStream[typing.Annotated[typing.Union[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent, o...
                 │    │       │        │            └ False
                 │    │       │        └ FinalRequestOptions(method='post', url='/responses', params={}, headers={'User-Agent': 'Agents/Python 0.0.0'}, max_retries=NO...
                 │    │       └ <class 'openai.types.responses.response.Response'>
                 │    └ <function AsyncAPIClient.request at 0x77ad4dbdcc10>
                 └ <openai.AsyncOpenAI object at 0x77ad47eb2730>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/openai/_base_client.py", line 1461, in request
    return await self._request(
                 │    └ <function AsyncAPIClient._request at 0x77ad4dbdcca0>
                 └ <openai.AsyncOpenAI object at 0x77ad47eb2730>
  File "/home/ubuntu/anaconda3/envs/agent-arena-backend/lib/python3.9/site-packages/openai/_base_client.py", line 1562, in _request
    raise self._make_status_error_from_response(err.response) from None
          │    └ <function BaseClient._make_status_error_from_response at 0x77ad4dbd2dc0>
          └ <openai.AsyncOpenAI object at 0x77ad47eb2730>

openai.NotFoundError: Error code: 404 - {'error': {'message': "Item with id 'fc_67d876754b2c8191bec6637d6c64a8d70ca151ec7ca34d36' not found.", 'type': 'invalid_request_error', 'param': 'input', 'code': None}}


Repro steps

computer_agent = Agent(
    name="Computer Agent",
    instructions="You are a real user computer agent, which means that you are connected to a real user's computer and granted full access to it. Your task is to help transfer the user's instructions to the computer and do the actions on the computer iteratively to finish the task. Also, you can handoff the task to the Search Agent as needed if you need to do online information retrieval.",
    tools=[ComputerTool(computer)],
    model="computer-use-preview",
    model_settings=ModelSettings(truncation="auto"),
    handoff_description="A real user computer environment to do GUI actions.",
)
search_agent = Agent(
    name="Search Agent",
    instructions="You are a searching agent connected to the Internet, you can help do information retrieval to gather useful information for the user's instruction. However, you cannot do any GUI actions on the computer unless you handoff the task to the Computer Agent.",
    tools=[WebSearchTool(user_location={"type": "approximate", "city": "New York"})],
    handoff_description="A search engine to do retrival actions."
)
computer_agent.handoffs.append(search_agent)
search_agent.handoffs.append(computer_agent)
all_agent = Agent(
    name="General Agent",
    instructions="You are a general digital agent. Your task is to help understand the user's instructions and help execute the task in a real computer environment, which is controlled by the Computer Agent. You can break down the task into smaller steps and delegate the steps to the corresponding agents. Remember always ground the task into the real computer environment by assigning the Computer Agent to do the actions. You can handoff the task to the Search Agent as needed if you need to do online information retrieval. But ALWAYS remember: you can only handoff the sub-task to one Agent at a time, which means you cannot handoff the task to both Computer Agent and Search Agent at the same time.",
    handoffs=[computer_agent,search_agent],
)
result = await Runner.run(instruction="can you help me search for the NBA finals result of last 5 years and then write the results in a new markdown file using MarkText, save it as 'NBA.md')

Call Flow

User requested: "can you help me search for the NBA finals result of last 5 years and then write the results in a new markdown file using MarkText, save it as "NBA.md""
General Agent correctly determined this required both search capabilities and computer interaction
General Agent attempted to make parallel tool calls:
transfer_to_search_agent (ID: fc_67d876754b2c8191bec6637d6c64a8d70ca151ec7ca34d36)
transfer_to_computer_agent (ID: fc_67d87675a94c81918773f9919a2b10b30ca151ec7ca34d36)
When processing these calls, the system attempted to retrieve the function call by ID, but received a 404 error

Expected Behavior

The handoff between agents should occur without any 404 errors. Function calls should remain accessible throughout the entire processing cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions