Repository navigation
Closed
Labels
Description
Description:
When using the OpenAI Agents SDK with tracing enabled (set_tracing_export_api_key(...)) and a non-OpenAI model (e.g., Gemini) for generation, handoff between agents fails with the following error:
openai.BadRequestError: Error code: 400 - {
'error': {
'message': "Invalid 'input[1].id': '__fake_id__'. Expected an ID that begins with 'fc'.",
'type': 'invalid_request_error',
'param': 'input[1].id',
'code': 'invalid_value'
}
}
Expected Behavior:
-
Handoffs should work the same way as when tracing is disabled, even with non-OpenAI models.
-
The tracing dashboard should either:
- Gracefully handle the absence of an OpenAI
fc_ID, or - Generate a synthetic trace ID to maintain the event graph.
- Gracefully handle the absence of an OpenAI
Actual Behavior:
- When tracing is disabled, the handoff works fine with Gemini.
- When tracing is enabled, the SDK sends a placeholder
"__fake_id__"to the OpenAI tracing API. - The OpenAI API rejects it because it is not a valid
fc_ID.
Why This Matters:
- Mixed-model workflows (e.g., using Gemini for generation + OpenAI tracing for workflow visibility) are currently blocked.
- Tools work fine in this setup — only handoffs break due to ID validation.
- This is inconsistent and limits multi-agent, multi-model orchestration.
Minimal Reproducible Example:
from agents import Agent, OpenAIChatCompletionsModel, function_tool, Runner, AsyncOpenAI, set_tracing_export_api_key
import os, asyncio
from dotenv import load_dotenv
load_dotenv()
# OpenAI key only for tracing
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
set_tracing_export_api_key(OPENAI_API_KEY)
# Non-OpenAI model client
external_client = AsyncOpenAI(
api_key=os.getenv("GEMINI_API_KEY"),
base_url=os.getenv("BASE_URL")
)
model = OpenAIChatCompletionsModel(
model=os.getenv("MODEL_NAME"),
openai_client=external_client
)
@function_tool
async def city_name_tool():
return "Karachi"
handof_agent = Agent(
"handof_agent",
handoff_description="Summarizes city info."
)
agent = Agent(
"agent",
instructions="Always call city_name_tool, then handoff to handof_agent.",
model=model,
tools=[city_name_tool],
handoffs=[handof_agent]
)
async def main():
result = await Runner.run(agent, input="Tell me about Karachi.")
print(result.final_output)
asyncio.run(main())Steps to Reproduce:
- Set
OPENAI_API_KEY(valid) for tracing. - Set up a non-OpenAI model in
external_client. - Enable tracing via
set_tracing_export_api_key(...). - Create two agents with a handoff between them.
- Run
Runner.run(...). - Observe the error.
Environment:
- SDK Version: openai-agents[viz]>=0.2.4
- Python Version: 3.13.2
- OS: Windows-11-10.0.26100-SP0
- Model for generation: Gemini 2.0 Flash (via
external_client) - Tracing target: OpenAI Tracing Dashboard
Possible Fix:
- Allow tracing to store handoff events without requiring a valid
fc_ID. - Generate synthetic but valid IDs for non-OpenAI model runs to preserve the trace graph.
Activity
seratch commentedon Aug 15, 2025
Hi, thanks for writing in. Unfortunately, this is a known limitation when you mix OpenAI's Responses API and other models' Chat Completions API, and there is no immediate plan to make some changes for it. If you need to do handoffs, please consider consistently using only Chat Completions models for the scenario.
github-actions commentedon Aug 23, 2025
This issue is stale because it has been open for 7 days with no activity.
exiao commentedon Sep 5, 2025
Just to be clear, the handoff_agent by default uses GPT-5 responses API. To fix this, you need to set the default or the handoff model to be using Chat Completions? @seratch
e.g.
fix: Replace __fake_id__ with unique ID to prevent message overwrites