Skip to content

'AgentOutputSchema' object has no attribute '__mro__' #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RoniFinTech opened this issue Apr 24, 2025 · 7 comments
Closed

'AgentOutputSchema' object has no attribute '__mro__' #597

RoniFinTech opened this issue Apr 24, 2025 · 7 comments

Comments

@RoniFinTech
Copy link

@x0day and @domino14 both your requests are now possible. See an example here for each:

https://github.com/openai/openai-agents-python/blob/main/examples/basic/non_strict_output_type.py

Originally posted by @rm-openai in #528

The above helped get past the Dict[str,any] issue, but now I'm seeing this error:
'AgentOutputSchema' object has no attribute 'mro'

I've tried downgrading/upgrading versions but no help.

I'm on pydantic 2.11.3
openai-agent 0.0.13

Any thoughts?

@rm-openai
Copy link
Collaborator

Can you share some code please?

@RoniFinTech
Copy link
Author

RoniFinTech commented Apr 24, 2025

Let's see if we can solve it with minimal code.

model:
openai-4o-mini

This is the definition of the supervisor agent:


class SupervisorResponse(BaseModel):
    """Structured output from the Supervisor Agent."""

    # response_to_user: str = Field(description="The final response to show to the user")
    processing_steps: List[str] = Field(..., description="Steps taken to process the query")
    items: List[dict] = Field(...,description="List of re-ranked items for the query.")

Agent definition:

model=settings.llm.OPENAI_MODEL_ID,
handoffs=[classifier_agent, search_agent, reranker_agent, response_agent],
tools=[get_conversation_history],
output_type=AgentOutputSchema(SupervisorResponse, strict_json_schema=False),

specialized agent:

class QueryType(str, Enum):
    """Types of queries that can be identified."""

    PRODUCT_SEARCH = "PRODUCT_SEARCH"
    OUTFIT_RECOMMENDATION = "OUTFIT_RECOMMENDATION"
    FASHION_ADVICE = "FASHION_ADVICE"
    BRAND_INQUIRY = "BRAND_INQUIRY"
    PRICE_COMPARISON = "PRICE_COMPARISON"
    GENERAL_QUESTION = "GENERAL_QUESTION"
    NON_FASHION = "NON_FASHION"


class ClassificationResult(BaseModel):
    """Result of a query classification."""

    query_type: QueryType = Field(..., description="The classified type of the query")
    confidence: float = Field(
        ..., description="Confidence score for the classification. score between 0.0 and 1.0"
    )
    is_fashion_query: bool = Field(..., description="Whether the query is related to fashion")
    reasoning: str = Field(..., description="Reasoning behind the classification")

Agent definition:

model=settings.llm.OPENAI_MODEL_ID,
output_type=AgentOutputSchema(ClassificationResult, strict_json_schema=False),

@rm-openai
Copy link
Collaborator

and can you also share the stack trace where you see that error?

@RoniFinTech
Copy link
Author

and can you also share the stack trace where you see that error?

It doesn't show much.
trace_id: trace_ddf7f7d8993e47629ad4a335ae71bc87

Image

@rm-openai
Copy link
Collaborator

Oh sorry I meant the Python stack trace (the full error message with all lines)

@RoniFinTech
Copy link
Author

Oh sorry I meant the Python stack trace (the full error message with all lines)

this is the only thing I'm seeing:

Error in supervisor agent: 'AgentOutputSchema' object has no attribute '__mro__'

@RoniFinTech
Copy link
Author

ahh looks like it was a venv problem...
I created a new one and the error went away.

thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants