This example demonstrates how to pass input to an agent as a list of Message objects, allowing for multi-turn conversations and context setup.

Code

cookbook/agents/input_and_output/input_as_messages_list.py
from agno.agent import Agent, Message

Agent().print_response(
    input=[
        Message(
            role="user",
            content="I'm preparing a presentation for my company about renewable energy adoption.",
        ),
        Message(
            role="assistant",
            content="I'd be happy to help with your renewable energy presentation. What specific aspects would you like me to focus on?",
        ),
        Message(
            role="user",
            content="Could you research the latest solar panel efficiency improvements in 2024?",
        ),
        Message(
            role="user",
            content="Also, please summarize the key findings in bullet points for my slides.",
        ),
    ],
    stream=True,
    markdown=True,
)

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Install libraries

pip install -U agno
3

Run Agent

python cookbook/agents/input_and_output/input_as_messages_list.py