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
{{ message }}
Repository navigation
invalid_request_error when using "chat_completions" with triage agent (gemini -> any other model) #237
openai.BadRequestError: Error code: 400 - {'error': {'code': 'invalid_request_error', 'message': "messages.1.content.1.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'", 'type': 'invalid_request_error', 'param': None}}
I get this error when one agent passes it's tool usage info and other stuff to my anthropic agent.
I see that the input looks like this: [{'content': 'Please search for my memory about smart cities', 'role': 'user'}, {'id': '__fake_id__', 'content': [{'annotations': [], 'text': '\n', 'type': 'output_text'}], 'role': 'assistant', 'status': 'completed', 'type': 'message'}, {'id': '__fake_id__', 'arguments': '{}', 'call_id': '', 'name': 'transfer_to_general_chat_agent', 'type': 'function_call'}, {'call_id': '', 'output': "{'assistant': 'General Chat Agent'}", 'type': 'function_call_output'}], and the fake ids are converted to empty strings afterwards, am i doing something wrong?
Debug information
Agents SDK version: (e.g. v0.0.4)
Python version (e.g. Python 3.12)
Repro steps
Ideally provide a minimal python script that can be run to reproduce the issue.
async def main_reproduce():
set_default_openai_api("chat_completions")
anthropic = AsyncOpenAI(
api_key="",
base_url="https://api.anthropic.com/v1/"
)
gemini = AsyncOpenAI(
api_key="",
base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
)
gen_agent = Agent(
name="General Chat Agent",
instructions="provide a response and use tools",
model=OpenAIChatCompletionsModel(model="claude-3-5-sonnet-20241022", openai_client=anthropic),
handoff_description="general",
)
triage = Agent(
name="Handoff agent",
instructions="choose the correct agent to respond",
model=OpenAIChatCompletionsModel(model="gemini-2.0-flash-001", openai_client=gemini),
handoffs=[gen_agent]
)
result = await Runner.run(triage, "Help me remember the past month")
print(result.final_output)
asyncio.run(main_reproduce())
Expected behavior
A clear and concise description of what you expected to happen.
using two gemini models works, even though the input_list still has empty call_id ids {'content': 'Help me remember the past month', 'role': 'user'}, {'id': '__fake_id__', 'arguments': '{}', 'call_id': '', 'name': 'transfer_to_general_chat_agent', 'type': 'function_call'}, {'call_id': '', 'output': "{'assistant': 'General Chat Agent'}", 'type': 'function_call_output'}, {'id': '__fake_id__',
Using two anthropic models works as well, they generate 'call_id' value
[{'content': 'Help me remember the past month', 'role': 'user'}, {'id': '__fake_id__', 'content': [{'annotations': [], 'text': "I'll help you transfer to the General Chat Agent who can assist with recalling and discussing past events.", 'type': 'output_text'}], 'role': 'assistant', 'status': 'completed', 'type': 'message'}, {'id': '__fake_id__', 'arguments': '{}', 'call_id': 'toolu_0166CqqT3JEj3XXFCqSRp2QM', 'name': 'transfer_to_general_chat_agent', 'type': 'function_call'}, {'call_id': 'toolu_0166CqqT3JEj3XXFCqSRp2QM', 'output': "{'assistant': 'General Chat Agent'}", 'type': 'function_call_output'}, {'id': '__fake_id__', 'content': [{'annotations': [], 'text': "I aim to help, but I should note that I don't have access to your personal memories or experiences from the past month. To help you remember, I can:\n\n1. Ask you questions about specific aspects you want to recall\n2. Help you walk through the timeline of the past month \n3. Discuss major public events that happened during that time\n\nWhat specifically would you like to remember about the past month? I can guide our conversation from there.", 'type': 'output_text'}], 'role': 'assistant', 'status': 'completed', 'type': 'message'}]
changed the title [-]invalid_request_error when using "chat_completions" with triage agent[/-][+]invalid_request_error when using "chat_completions" with triage agent (gemini -> any other model)[/+]on Mar 19, 2025
Maybe for gemini specifically it would be possible to replace call_id with some random id? Feels hacky, but would be really nice to have all of the models available for agents 🙏
Even though LiteLLM does great job for the interoperability, some models may not fully support some features this SDK provides (e.g., Gemini models do not allow tools and structured outputs at a time). That said, for simple use cases, LiteLLM provides seamless integration.
Let us close this issue now, but if you encounter any issues with LiteLLM, please feel free to open a new issue.
Activity
kmariunas commentedon Mar 19, 2025
using two gemini models works, even though the input_list still has empty call_id ids
{'content': 'Help me remember the past month', 'role': 'user'}, {'id': '__fake_id__', 'arguments': '{}', 'call_id': '', 'name': 'transfer_to_general_chat_agent', 'type': 'function_call'}, {'call_id': '', 'output': "{'assistant': 'General Chat Agent'}", 'type': 'function_call_output'}, {'id': '__fake_id__',kmariunas commentedon Mar 19, 2025
Using two anthropic models works as well, they generate 'call_id' value
[{'content': 'Help me remember the past month', 'role': 'user'}, {'id': '__fake_id__', 'content': [{'annotations': [], 'text': "I'll help you transfer to the General Chat Agent who can assist with recalling and discussing past events.", 'type': 'output_text'}], 'role': 'assistant', 'status': 'completed', 'type': 'message'}, {'id': '__fake_id__', 'arguments': '{}', 'call_id': 'toolu_0166CqqT3JEj3XXFCqSRp2QM', 'name': 'transfer_to_general_chat_agent', 'type': 'function_call'}, {'call_id': 'toolu_0166CqqT3JEj3XXFCqSRp2QM', 'output': "{'assistant': 'General Chat Agent'}", 'type': 'function_call_output'}, {'id': '__fake_id__', 'content': [{'annotations': [], 'text': "I aim to help, but I should note that I don't have access to your personal memories or experiences from the past month. To help you remember, I can:\n\n1. Ask you questions about specific aspects you want to recall\n2. Help you walk through the timeline of the past month \n3. Discuss major public events that happened during that time\n\nWhat specifically would you like to remember about the past month? I can guide our conversation from there.", 'type': 'output_text'}], 'role': 'assistant', 'status': 'completed', 'type': 'message'}][-]invalid_request_error when using "chat_completions" with triage agent[/-][+]invalid_request_error when using "chat_completions" with triage agent (gemini -> any other model)[/+]rm-openai commentedon Mar 19, 2025
Yeah looks like this is an issue with Gemini. Specifically, when I ran this curl snippet: https://ai.google.dev/gemini-api/docs/openai#function-calling
The response has empty IDs for the tool call:
That is incompatible with openai, anthropic etc.
I'm not totally sure how to work around this - any suggestions?
kmariunas commentedon Mar 19, 2025
Maybe for gemini specifically it would be possible to replace call_id with some random id? Feels hacky, but would be really nice to have all of the models available for agents 🙏
kmariunas commentedon Mar 27, 2025
hey, any updates on ths?
moseshu commentedon May 1, 2025
I got this error: Error code: 404 - {'type': 'error', 'error': {'type': 'not_found_error', 'message': 'Not Found'}}
how to solve it?
seratch commentedon Sep 22, 2025
Thanks for sharing this and we're sorry for our slow response here.
Non-OpenAI models often aren't fully compatible with OpenAIChatCompletionsModel even thought those platforms say they're compatible. Our latest recommendation is to use LiteLLM as the adapter for those platforms rather than trying to use OpenAIResponsesModel / OpenAIChatCompletionsModel with different model names and endpoints: https://openai.github.io/openai-agents-python/models/litellm/
Even though LiteLLM does great job for the interoperability, some models may not fully support some features this SDK provides (e.g., Gemini models do not allow tools and structured outputs at a time). That said, for simple use cases, LiteLLM provides seamless integration.
Let us close this issue now, but if you encounter any issues with LiteLLM, please feel free to open a new issue.