---
type: email
from: abdulhadi240 <notifications@github.com>
subject: [openai/openai-agents-python] TypeError: Cannot instantiate

 typing.Union (Issue #1411)
received: 2026-03-05 09:56:30
date_header: Sat, 09 Aug 2025 22:38:57 -0700
priority: normal
status: awaiting_approval
uid: 27013
---

## Email Content

**From:** abdulhadi240 <notifications@github.com>
**Subject:** [openai/openai-agents-python] TypeError: Cannot instantiate

 typing.Union (Issue #1411)
**Date:** Sat, 09 Aug 2025 22:38:57 -0700

### Body (preview)

abdulhadi240 created an issue (openai/openai-agents-python#1411)



### Below is my full code 



from __future__ import annotations

import asyncio

from typing import Optional

from tavily import TavilyClient

from agents import Agent, Runner, function_tool, set_tracing_disabled

from agents.extensions.models.litellm_model import LitellmModel

from agents.extensions.visualization import draw_graph

from openai import AsyncOpenAI

from openai.types.responses import ResponseTextDeltaEvent

from google.colab import userdata



# Get API keys

GEMINI_API_KEY = userdata.get('GOOGLE_API_KEY')

TAVILY_API_KEY = "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"  # Consider moving to userdata



# Model configuration

MODEL = 'gemini/gemini-2.0-flash'



# Initialize Tavily client for research

tavily_client = TavilyClient(TAVILY_API_KEY)



# Disable tracing for performance

set_tracing_disabled(disabled=True)





@function_tool

def send_email(body: str) -> str:

    """Send an email with the specified body text."""

    print(f"Sending email with body: {body[:100]}...")  # Show first 100 chars

    return "The email has been sent successfully"





@function_tool

def research(query: str) -> list:

    """Perform web research on a given query."""

    print(f"Researching: {query}")

    response = tavily_client.search(query=query)

    return response["results"]





# Email Agent

email_agent = Agent(

    name="Email Agent",

    instructions="""

        You are the Email Agent.

        Your sole responsibility is to send emails using the `send_email` tool.

        The `send_email` tool has a single parameter: `body` (string), which is the full text of the email.



        When you are asked to send an email:

        1. Extract the exact email text from the user's request (do not add or remove words unless explicitly instructed).

        2. Pass the complete email text as the `body` parameter to the `send_email` tool.



        Do not answer general questions, perform r

---

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