Skip to main content
expected_output.py
"""
Expected Output
===============

Demonstrates setting a team-level `expected_output` to describe the desired
run result shape.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.team import Team

# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
incident_analyst = Agent(
    name="Incident Analyst",
    model=OpenAIResponses(id="gpt-5-mini"),
    instructions=[
        "Extract outcomes and risks clearly.",
        "Avoid unnecessary speculation.",
    ],
)


# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
incident_team = Team(
    name="Incident Reporting Team",
    model=OpenAIResponses(id="gpt-5-mini"),
    members=[incident_analyst],
    expected_output=(
        "Three sections: Summary, Impact, and Next Step. "
        "Keep each section to one sentence."
    ),
    instructions=[
        "Summarize incidents in a clear operational style.",
        "Prefer plain language over technical jargon.",
    ],
)


# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    incident_team.print_response(
        (
            "A deployment changed the auth callback behavior, login requests increased by 12%, "
            "and a rollback script is already prepared."
        ),
        stream=True,
    )

Run the Example

1

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2

Install dependencies

uv pip install -U agno openai
3

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4

Run the example

Save the code above as expected_output.py, then run:
python expected_output.py
Full source: cookbook/03_teams/04_structured_input_output/expected_output.py