---
type: email
from: Muhammad Huzaifa <notifications@github.com>
subject: [openai/openai-agents-python] TypeError: 'NoneType' object is not

 subscriptable in OpenAIChatCompletionsModel when Runner.run receives

 orchestrator_result.to_input_list() with Gemini API (Issue #1732)
received: 2026-03-06 07:30:59
date_header: Sun, 14 Sep 2025 03:32:18 -0700
priority: normal
status: awaiting_approval
uid: 30370
---

## Email Content

**From:** Muhammad Huzaifa <notifications@github.com>
**Subject:** [openai/openai-agents-python] TypeError: 'NoneType' object is not

 subscriptable in OpenAIChatCompletionsModel when Runner.run receives

 orchestrator_result.to_input_list() with Gemini API (Issue #1732)
**Date:** Sun, 14 Sep 2025 03:32:18 -0700

### Body (preview)

MHuzaifaYounus created an issue (openai/openai-agents-python#1732)



**Title: TypeError: 'NoneType' object is not subscriptable in OpenAIChatCompletionsModel when Runner.run receives orchestrator_result.to_input_list() with Gemini API**



**Description:**

I am consistently encountering a `TypeError: 'NoneType' object is not subscriptable` within the `agents` library's `OpenAIChatCompletionsModel` when attempting to pass the output of `orchestrator_result.to_input_list()` as input to a subsequent `Runner.run` call for a `synthesizer_agent`. This occurs despite both the `synthesizer_agent` and `run_config` being explicitly configured to use the `gemini-2.5-flash` model via an `AsyncOpenAI` client pointed to the Google Generative Language API.



The error points to a situation where `response.choices[0].message` is `None` after an API call to Gemini, indicating that the LLM is not returning an expected message object when provided with the structured conversation history from `to_input_list()`.



**Steps to Reproduce:**



1.  **Environment Setup:**

    *   Ensure `GEMINI_API_KEY` is set in your `.env` file.

    *   Install necessary dependencies (e.g., `pip install openai-agents openai python-dotenv`).



2.  **Code (`practice/agent_as_tool.py`):**

    ```python

    import asyncio

    import os



    from agents import Agent, ItemHelpers, MessageOutputItem, OpenAIChatCompletionsModel, RunConfig, Runner, trace

    from dotenv import load_dotenv

    from openai import AsyncOpenAI



    load_dotenv()

    gemini_api_key = os.getenv("GEMINI_API_KEY")



    if not gemini_api_key:

        raise ValueError("GEMINI_API_KEY not found in .env file. Please create a .env file and add your key.")



    # Enable verbose logging for debugging (Optional)



    external_client = AsyncOpenAI(

        api_key=gemini_api_key,

        base_url="https://generativelanguage.googleapis.com/v1beta/openai/",

    )

    model = OpenAIChatCompletionsModel(

        model="gem

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
