Skip to content

Title: Handoff fails with Invalid 'input[1].id': '__fake_id__' when using non-OpenAI models and OpenAI tracing #1485

Closed

Description

@123Mismail

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.

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:

  1. Set OPENAI_API_KEY (valid) for tracing.
  2. Set up a non-OpenAI model in external_client.
  3. Enable tracing via set_tracing_export_api_key(...).
  4. Create two agents with a handoff between them.
  5. Run Runner.run(...).
  6. 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

  1. added
    bug
    on Aug 15, 2025
  2. added
    question
    and removed
    bug
    on Aug 15, 2025
  3. seratch commented on Aug 15, 2025

    @seratch
    Member

    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.

  4. github-actions commented on Aug 23, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open for 7 days with no activity.

  5. exiao commented on Sep 5, 2025

    @exiao

    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.

    set_default_openai_api("chat_completions")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions